-
Notifications
You must be signed in to change notification settings - Fork 287
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
set-cookie support in isomorphic-fetch in nodeJs application (question) #153
Comments
I am hitting the same issue. I am expecting to receive cookies but they are always unset. Any info ? |
You would have to implement this yourself, something like…… fetch('https://mattandre.ws/endpoint-that-sets-set-cookie')
.then(res => {
const setCookie = res.headers.get('set-cookie');
const cookie = setCookie.substr(0, setCookie.indexOf(';'))
return fetch('https://mattandre.ws/endpoint-that-relies-on-cookies-set', {
headers: { Cookie: cookie }
});
}); |
Thanks @matthew-andrews . This would obviously work, but could I know why it is not possible to mock The best thing would be to globally use some store for that instead of catching the cookie ourselves, any idea how it could be done ? I assume this will require some change in the library. |
Hmm, I think that it might be a little dangerous to do by default. If you're using Cookies on the server side you are probably emulating logging in as a user. So by sharing that globally on the server side you have quite high risk of accidentally allowing users to access each other's data…… |
In case it helps anyone else, I was trying to use this in jest (jsdom) to test a browser app and cookies were not working. whatwg-fetch works fine in this regard, as an alternative. |
I am using isomorphic-fetch (2.2.1) in a NodeJS application. The response from server comes with set-cookie headers, but my subsequent isomorphic-fetch calls do not include the cookies. I am using credentials: "same-origin" (also tried credentials: "include" but not luck.
Does isomorphic fetch set-cookies when it is used in nodeJS (not a browser) ?
[also asked this in SO, with not response]
The text was updated successfully, but these errors were encountered: