nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.94k stars 925 forks source link

Sanctum - LoggedIn State is not updated on static site when moving it to server #1307

Closed sarik-k closed 3 years ago

sarik-k commented 3 years ago

Version

module: nuxt:

Nuxt configuration

mode:

Nuxt configuration

What is expected?

After getting a 200 response from /login endpoint, it should update the state accordingly, hit the /user endpoint and redirect to home.

What is actually happening?

It works as expected when running npm run dev and npm run generate && npm run start. But when I deploy the dist folder to a different server, isLoggedIn state is always false in vuex even after getting a 200 response from /login from server. /user is never hit. Tested locally in Laragon, in a Linux Apache server and Netlify

Steps to reproduce

Setup a basic nuxt app with auth-next and use Laravel sanctum as the provider

Additional information

I have tried with ssr false as well, same issue.

Checklist

Code: https://github.com/sarik-k/laravel-nuxt-boilerplate/tree/master/client Loom: https://www.loom.com/share/4f2c5b4ec5294dadb522b2da7e128789

sarik-k commented 3 years ago

It was an issue with cookies and domain. I forgot to set SANCTUM_STATEFUL_DOMAINS in env.