NodeJS express response cookie does not set cookie in client.

Cing Sian Dal
Jun 6, 2021

--

In your NodeJS, you declare to respond with a cookie in its header:

response.cookie("accessToken", accessToken, {
expires: new Date(Date.now() + 60_000), // 60 seconds
}

But the client does not save cookies from its reponse header because you must specify withCredential in your axio configuration:

const instance = axios.create({
baseURL: 'http://www.google.com',
withCredential: true
});

--

--

Cing Sian Dal
Cing Sian Dal

Written by Cing Sian Dal

Don’t follow me. I wrote junks here. Follow me on Twitter instead.

No responses yet