I have a front end Angular application that is hosted on dev.subdomain.mydomain.com
. The application makes HTTP requests to an .net CORE API hosted on dev.api.mydomain.com
. My angular application has a session cookie associated to it with the following security properties:
Secure=true
HttpOnly=true
SameSite=None
Domain=.mydomain.com
I want the cookie to be sent to the backend server on every request but for some reason the request gets sent without it.
I added an angular interceptor that adds the withCredentials
option to the outgoing request
req = req.clone({
headers: req.headers.set('Content-Type', 'application/json'),
withCredentials: true
});
But that didn't help either. Tested this both in Chrome and Firefox, same results.
Update:
I noticed that the cookie does get sent on the initial http request (going to the server to get the angular application), but ajax requests using httpClient
do not get sent with the cookie
Update 2:
I've set my API so that the following headers are included in the preflight response:
Access-Control-Allow-Origin: https://dev.subdomain.mydomain.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type,withcredentials
Access-Control-Allow-Methods: GET
Cookie still not being sent.