I've been wracking my brain trying to figure out why this get request isn't sending an authentication cookie along with it, and can't figure it out.
The request in question is as follows:
this.http.get(`${this.url}/api/public/schedules`, {observe: 'body', responseType: 'json', withCredentials: true});
With the cookie being set beforehand (which I've double checked, it is already set when this request goes out) with:
this.CookieService.set("token", token, undefined, undefined, undefined, false);
Chrome dev tools show that the cookie exists, and secure is set to false, but the cookie is never sent with any requests. I've verified this both client-side (chrome says no cookies are sent with the request) and server-side (logging the cookies associated with the request always comes up blank.)
Here's my relevant server-side code:
app.use((req, res, next) => { //log all requests
console.log(`Received ${req.method} request for ${req.url}`);
console.log("Cookies: " + JSON.stringify(req.cookies));
res.append('Access-Control-Allow-Origin', ['http://localhost:4200']); //adding headers here
res.append('Access-Control-Allow-Credentials', true);
res.append('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.append('Access-Control-Allow-Headers', 'Content-Type');
next(); //then continue
});
When I send the same request with a cookie in insomnia, it gets properly logged, so I'm not sure what's going on. Any help would be appreciated.