Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 9d58d8f

Browse files
authored
docs: clarify assumptions made by preload (#1135)
1 parent fffdbc6 commit 9d58d8f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

site/content/docs/04-preloading.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ To fix this, Sapper provides `this.fetch`, which works on the server as well as
8383
</script>
8484
```
8585

86-
Note that you will need to use session middleware such as [express-session](https://github.com/expressjs/session) in your `app/server.js` in order to maintain user sessions or do anything involving authentication.
86+
It is important to note that `preload` may run on either the server or in the client browser. Code called inside `preload` blocks:
87+
- should run on the same domain as any upstream API servers requiring credentials; otherwise, `credentials: 'include'` cannot guarantee access to 3rd party session cookies
88+
- should not reference `window`, `document` or any browser-specific objects
89+
- should not reference any API keys or secrets, which will be exposed to the client
90+
91+
If you are using Sapper as an authentication/authorization server, you can use session middleware such as [express-session](https://github.com/expressjs/session) in your `app/server.js` in order to maintain user sessions.
8792

8893

8994
#### this.error

0 commit comments

Comments
 (0)