nhedger/nuxt-sanctum

Authenticated false after login and reload

andyjamesn opened this issue · 0 comments

Describe the bug
I am able to setup login just fine, but on a reload of the page. Authenticated is false when using const { authenticated } = useSanctum();

I installed a fresh Nuxt App and then created an index and welcome page. Setup the login and xsrf token urls etc.

Login works fine, gets the csrf token, logs me in and hits the /me route and navigates to welcome which shows authenticated is true. I also have a button on that page that returnes user from const { user } = useSanctum();

The user returns fine. Authenticated is false when using const { authenticated } = useSanctum(); also user when I call const { user } = useSanctum(); is undefined.

If I call the me endpoint using useSanctumFetch it get's the user fine.

I also see this notice in the console

[nuxt] [useFetch] Component is already mounted, please use $fetch instead.

Version of nuxt-sanctum
0.1.5

Minimal reproduction repository
https://https://github.com/andyjamesn/nhedger-nuxt-sanctum-test

Expected behavior
authenticated and user from the composables should show me as logged in