CORS cookie not saved in browser

Viewed 1231

I have a http endpoint, accessible through CORS from my client. A cookie is set when a request is sent to this url. This cookie reaches the client (screenshot from Chrome's dev tool):

enter image description here

However, it is not saved (screenshot from Chrome's Cookies window):

enter image description here

Why is the cookie not saved in the browser? I tried with Chrome and Firefox, same behaviour.

Response Headers:

Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:4200
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json;charset=UTF-8
Date: Sat, 08 Sep 2018 20:24:11 GMT
Expires: 0
Pragma: no-cache
Set-Cookie: guestId=79f0c026-c8f9-4820-a825-15381116d714; Max-Age=157680000; Expires=Thu, 07-Sep-2023 20:24:11 GMT
Transfer-Encoding: chunked
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
1 Answers

The request should have the 'withCredentials' flag.

e.g. in Angular2+:

const options = { withCredentials: true };
const dataObservable = this.http.get(url, options)
Related