Open tashburn opened 7 years ago
Are you sure? This is a very common use case. I believe credentials
really should work…
@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.
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' }
});
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
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'
orcredentials: 'include'
to the fetch options did not make a difference.