atinux / nuxt-auth-utils

Add Authentication to Nuxt applications with secured & sealed cookies sessions.
MIT License
976 stars 91 forks source link

Impossible to login using Safari with localhost #78

Closed vinceglb closed 7 months ago

vinceglb commented 7 months ago

I tried to use nuxt-auth-utils with Safari on macOS 14.4.1, but I've never been able to get it to work.

The cookie nuxt-session is never received on Safari, but it's working on Arc.

To reproduce:

But I can get https://todos.nuxt.dev/ works on Safari.

Is there anything I'm missing?

raggesilver commented 7 months ago

I was facing this issue today, @vinceglb. Safari is technically in the right here... The cookie set by this library uses secure: true (as it should), which means it only works on sites being served via HTTPS (not HTTP).

Following these instructions will allow you to run Nuxt in dev mode served over HTTPS.

You can use the following commands to generate the certificates you need.

openssl genrsa 2048 > server.key
chmod 400 server.key
openssl req -new -x509 -nodes -sha256 -days 365 -key server.key -out server.crt
# https://stackoverflow.com/a/57895543/5609203
vinceglb commented 7 months ago

Good catch, Safari doesn't seem to accept secure cookies on localhost! Thank you 🙏