I'm working in an app with React with Next.js in the frontend and Node.js with Express in the backend. My login works with cookies, in localhost all works better, but when I make the deploy, I have two apps. My frontend app is deployed in now.sh and My backend app is deployed in Heroku. When I try to make a login request in production, all works fine, the cookies are in the response and the header 'Set-Cookie' exists. But my browser (Chrome) doesn't store the cookie in Application >> Cookies and obviously my frontend app doesn't know about the cookie and it's undefined
Here is my code:
Server.js
app.use(
cors({
credentials: true,
origin: process.env.CLIENT_URL, // contains the frontend url
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"],
allowedHeaders: ["Content-Type", "Authorization"],
})
);
Auth routes when I make the response to the frontend
return res
.cookie("token", session.token, {
httpOnly: true,
sameSite: "None",
maxAge: 1209600000,
secure: process.env.NODE_ENV === "production",
})
.status(200)
.json({
success: true,
token: session.token,
user,
});
Making the request in the frontend
const { data } = await Axios.post(login, // backend url to make the request
{ email, password },
{ withCredentials: true });
Response in the browser

Cookie info in the cookie tab
