Fetching cross origin request, Chrome cannot read set-cookie
even if I set the credentials: 'include'
and the server gives:
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://127.0.0.1:3000
It's a react(^16.6.3) project with fetch api
I tried Chrome, Safari, Firefox and mobile browsers, but all these browsers can not read and save cookies. In chrome there's no Set-Cookie
field, but exist in Safari and Firefox.
And when I use postman to test it, it will be ok, the next request will send the cookies.
fetch('http://API_ROOT/api', {
credentials: 'include',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=utf-8',
},
method: 'POST',
body: JSON.stringify({})
});
Expect the browser to save and send cookie.