Skip to content
Advertisement

res.setHeader(“Set-Cookie”, …) is not setting the cookie in Node / Express

I have tried

JavaScript

and

JavaScript

and I have tried to set the cookie outright with

JavaScript

but no cookie is set when I examine the res, and no cookie is received in my frontend. Everything is run locally. I do not understand why.

Advertisement

Answer

I found the answer. When using fetch() from the front end I didn’t set the credentials flag to include. When I included the flag it worked instantly.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement