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

Clarify assumptions made by preload #1135

Merged
merged 3 commits into from
May 13, 2020
Merged

Conversation

natevaughan
Copy link
Contributor

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

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.
Copy link
Member

@arxpoetica arxpoetica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@antony
Copy link
Member

antony commented Mar 30, 2020

Thanks @natevaughan - this is very clear, and I think is a big tripping point for new users.

@natevaughan
Copy link
Contributor Author

Great, glad it helps. And thank you for your help today @antony

@natevaughan
Copy link
Contributor Author

What's the Sapper release cycle like?

@antony
Copy link
Member

antony commented Apr 17, 2020

@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.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"explosed" should be "exposed"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -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
Copy link
Member

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?

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

Copy link
Member

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

@Conduitry Conduitry merged commit 9d58d8f into sveltejs:master May 13, 2020
@natevaughan natevaughan deleted the patch-1 branch August 22, 2020 13:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants