Wednesday, 19 August 2020

Axios won't send cookies to node.js express server after deploying express server to another domain than localhost

Axios won't send cookies to node.js express server after deploying express server to another domain than localhost...Now the domain is called auth.example.com and this express server is using cors and session library,How can I fix this?express server setup, this setup works when I run local on my machine on localhost:9000:app.use(session( { name: 'session-id', resave: false, saveUninitialized: false, cookie: { secure: false, sameSite: 'none', httpOnly: true, maxAge: 345600000 } } )); app.use(cors({ origin: true, credentials: true })); app.options('*', cors({ origin: true, credentials: true })); ​Axios request:​const res = await axios .get(`auth.example.com/getUser`, { withCredentials: true, }) .then((response) => { return response.data; }) ​When I check the request on chrome devtool see that the cookie is filtered out, and it say no cookies were sent.

Submitted August 19, 2020 at 04:44PM by exilen

No comments:

Post a Comment