Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching during SSR (using Next) should include cookies #141

Open
tashburn opened this issue Jul 3, 2017 · 4 comments
Open

Fetching during SSR (using Next) should include cookies #141

tashburn opened this issue Jul 3, 2017 · 4 comments

Comments

@tashburn
Copy link

tashburn commented Jul 3, 2017

Cookies are included in the Express routing when the fetch code runs on the browser, but when run during SSR with Next, the cookies are not available. I'd expect them to be.

Adding credentials: 'same-origin' or credentials: 'include' to the fetch options did not make a difference.

@matthew-andrews
Copy link
Owner

Are you sure? This is a very common use case. I believe credentials really should work…

@tashburn
Copy link
Author

tashburn commented Jul 6, 2017

@matthew-andrews in discussions with the Next people, one said "I have the same problem with isomorphic-fetch", and another said "You'll have to manually pass the cookies off (reading from req) and pass them to axios / isomorphic-fetch"

Any idea how I "pass the cookies" to isomorphic-fetch?

credentials only works when the fetch happens on the browser client. when the fetch happens during SSR, credentials does not work.

@matthew-andrews
Copy link
Owner

Oh right, on the server, I see…… I think you'd need to add the cookie header manually in that environment. Something like this…

fetch(url, {
  headers: { Cookie: 'name=value' }
});

@matthew-andrews
Copy link
Owner

on the server, isomorphic-fetch just proxies node-fetch underneath, which as you say does not implement credentials:- https://github.com/bitinn/node-fetch#class-request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants