amrnn90 / breeze-nuxt

An application / authentication starter kit frontend in Nuxt3 for Laravel Breeze.
MIT License
193 stars 30 forks source link

Persist login on reload #37

Open andyjamesn opened 2 months ago

andyjamesn commented 2 months ago

I am not sure if I am missing something with how this should work.

I pulled down a fresh version of this repo installed everything and connected it to my Laravel backend.

Everything works great, I can login, logout, use middleware etc. I can navigate around to pages and everything works.

But if I reload the page on welcome for example which has auth middleware I am taken back to the login page.

Is this the expected behaviour and I need to add some code to persist the login?

andyjamesn commented 2 months ago

I may be wrong but it seems like the auth plugin is checking for if the user is undefined. But on reload the user is null not undefined. This means await fetchCurrentUser(); doesn't get called so the user is not populated.