Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxAge is ignored #168

Open
Rashe opened this issue Aug 19, 2024 · 0 comments
Open

maxAge is ignored #168

Rashe opened this issue Aug 19, 2024 · 0 comments

Comments

@Rashe
Copy link

Rashe commented Aug 19, 2024

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" })
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants