I made an app including Vue.js client app and Node.js Express server app. My client sents axios GET requests with cookies to the express server.
The problem is, the server deployed on Heroku doesn't get the cookies, although the local server works well. It seems very weird because the server on Heroku actually gets the cookies when I test it with Postman.
const res = await axios.get(endpoint + '/api/user/auth', { withCredentials: true })
This is my client's axios request code.
const corsConfig = {
origin: true,
credentials: true
}
app.use(cors(corsConfig))
This is a part of the index.js file configuring CORS of the express server.
let auth = (req, res, next) => {
let token = req.cookies.x_auth
console.log(req.cookies)
console.log('token: ', token)
This is the part of a route getting cookies.
Local Vue.js client - Local express server => COOKIES
Local Vue.js client - Heroku express server => NO COOKIES
Deployed Vue.js client - Heroku express server => NO COOKIES
Postman request - Heroku express server => COOKIES
I don't even know whether it's a problem of the server or the client. All requests work just fine but getting cookies.