isomorphic-fetch: Fail to save Set-cookies data to browser

I am using Chrome 48 and found that it is not able to save the set-cookies details into the browser and therefore I am not able to use isomorphic-fetch to do any cookies/ login related api request. I have been calling an api by code like this: fetch("/accounts/register/", { method: 'post', headers: { "X-CSRFToken": CSRF.getToken(), "Accept": 'application/json', "Content-Type": 'application/json' }, body: JSON.stringify(payload) }).then(response => { if (response.status == 302) { dispatch(receiveRegistration()) return Promise.reject() } else { return response } }).then(response => response.json().then(json => ({json, response})) ).then(({ json, response }) => { if (!response.ok) { dispatch(failRegistration(json)) } else { dispatch(receiveRegistration()) } })

Please kindly advise if I have been using isomorphic-fetch wrongly or this is actually caused by the underlying “fetch polyfilly” library.

Thanks a lot.

About this issue

Most upvoted comments

It’s weird. In your case in https://github.com/koajs/koa/issues/689, the requests are all belong to the same domain which is 9.xiaojukeji.com, i think {credentials: 'same-origin'} is not necessary. Did i miss something?

My call to fetch endeup like this fetch(url, {credentials: ‘same-origin’}) And it worked for me!

@luckydrq yeah. about receiving not sending, it’s also the scene I came cross. I found if there is no {credentials: 'same-origin'} ,isomorphic-fetch would’t send browser cookie in get request, and then browser would’t save cookies even if the response carried cookies.

then I found jquery ajax send cookies either receiving or sending, and when I add the credentials it works well. so I guess that’s the key.