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

Cookies blocked on http localhost for Ffox and Chrome #100

Open
weisisheng opened this issue Feb 4, 2025 · 5 comments
Open

Cookies blocked on http localhost for Ffox and Chrome #100

weisisheng opened this issue Feb 4, 2025 · 5 comments

Comments

@weisisheng
Copy link

I notice this code sets cookies correctly:

  const encryptedSession = await signToken(session);
  (await cookies()).set('session', encryptedSession, {
    expires: expiresInOneDay,
    httpOnly: true,
    secure: true,
    sameSite: 'lax',
  });

Still my cookies get blocked and so I don't get a valid login. Appreciate any trailheads, tips, tricks. TIA.

@weisisheng
Copy link
Author

I know I am threatening a curse from the auth gods, just commented these out so I can get exploring:

// secure: true,
// sameSite: 'lax',

@tadeumaia
Copy link

Chrome works correctly for me, but localhost safari is broken.

@csarnoult
Copy link

localhost safari is broken for me, too. And like @tadeumaia, my chrome works just fine. I'm unsure what the issue is with Safari. Is anyone else having this problem and do you know a solution?

@tadeumaia
Copy link

tadeumaia commented Mar 4, 2025

localhost safari is broken for me, too. And like @tadeumaia, my chrome works just fine. I'm unsure what the issue is with Safari. Is anyone else having this problem and do you know a solution?

Through trial and error I found out secure: true does not work on safari localhost. Configuring it to change depending on the ENV.prod fixed it for me. Change it at the login set session function.

@chungweileong94
Copy link
Contributor

Both secure and sameSite options only works with https.
You can either conditionally turn off the options on local development, or create your own self-signed SSL by running next dev --experimental-https.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants