cookie
cookie copied to clipboard
maxAge is ignored
I try to set maxAge for cookie, but no matter what I do the expiration is always "Session"
The frontend and backend are not on the same domain.
Btw, it works on localhost
My code:
async function login(req, res) {
try {
const { email, password } = req.body
const { token, refreshToken, user } = await authService.login({ email, password })
res.setCookie("refreshToken", refreshToken, {
httpOnly: true,
sameSite: "None",
secure: true,
path: "/",
signed: true,
maxAge: 30 * 24 * 60 * 60
}).send({ accessToken: token, user })
} catch (e) {
console.error(e)
return res.status(401).send({ error: "Unauthorized" })
}
}