Monday, 29 October 2018

Javascript fetch Cookie not set in Chrome and Firefox for iPhone

i'm trying to understand this behaviour for a university project.

I've a react web application deployed on google cloud and a Go server also deployed on google cloud.

The web application uses the API served by my Go server.

The app seems to work pretty well using Chrome and Firefox browsers in a desktop environment and on Android smartphones but when i use it with the same browsers on iOS (iPhone8) the API calls do not contain the cookie i need to authenticate the user in my Go server. Safari also does work good, so i see this behaviour only with Chrome and Firefox on my iPhone

These are the headers of two calls at the same API, the first made with Safari and the second made with Firefox:

Safari (iOS 12.0.1)

GET /example/users HTTP/1.1
Host: api-server.com
Connection: close
Accept-Language: en-gb
Cookie: default=MTU0MDM3MTA0... /*COOKIE IS SET HERE*/
Dnt: 1
Origin: https://example.com
Referer: https://example.com/
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_0_1 like Mac OS X) 
            AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 
            Mobile/15E148 Safari/604.1
X-Cloud-Trace-Context: 38640...

Firefox (v14.0)

GET /example/users HTTP/1.1
Host: api-server.com
Connection: close
Accept-Language: en-gb
Origin: https://example.com
Referer: https://example.com/
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_0_1 like Mac OS X) 
            AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/14.0b12646 
            Mobile/16A404 Safari/605.1.15
X-Cloud-Trace-Context: cb5ff...

When i send the request using fetch, i set the option credentials: 'include' but as you can see the second call does not set the cookie i need...

What am i missing?

Thank you for your help



from Javascript fetch Cookie not set in Chrome and Firefox for iPhone

No comments:

Post a Comment