-
-
Notifications
You must be signed in to change notification settings - Fork 428
Conversation
Included here are a few assumptions that I stumbled over when getting to know `preload`. I've updated the docs to spell them out to hopefully save others a little bit of time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @natevaughan - this is very clear, and I think is a big tripping point for new users. |
Great, glad it helps. And thank you for your help today @antony |
What's the Sapper release cycle like? |
@natevaughan right now there isn't really one. We're focussed on Svelte for the time-being. We're slowly merging PRs as time allows. |
site/content/docs/04-preloading.md
Outdated
It is important to note that `preload` may run on either the server or in the client browser. Code called inside `preload` blocks: | ||
- should run on the same domain as any upstream api servers requiring credentials; otherwise `credentials: 'include'` cannot guarantee access to 3rd party session cookies | ||
- should not reference `window`, `document` or any browser-specific objects | ||
- should not reference any api keys or secrets, which will be explosed to the client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"explosed" should be "exposed"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
site/content/docs/04-preloading.md
Outdated
@@ -83,7 +83,12 @@ To fix this, Sapper provides `this.fetch`, which works on the server as well as | |||
</script> | |||
``` | |||
|
|||
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. | |||
It is important to note that `preload` may run on either the server or in the client browser. Code called inside `preload` blocks: | |||
- should run on the same domain as any upstream api servers requiring credentials; otherwise `credentials: 'include'` cannot guarantee access to 3rd party session cookies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't credentials: 'include'
send the cookies even to other domains?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benmccann Doesn't that depend on how a project has their CORS settings configured? I'm pretty new to NodeJS so I might be mistaken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cookies can't be cross-domain. Cookies from .domain.com
will only ever be sent to .domain.com
Included here are a few assumptions that I stumbled over when getting to know
preload
. I've updated the docs to spell them out to hopefully save others a little bit of time.See #1134