Reputation:
Nuxtjs-auth module was working fine when my local instances of the frontend and backend app were both running on localhost (frontend was on port 3000, backend was on port 8000)
I dockerized the containers; now the frontend is available at http://app.test and the backend at http://api.app.test. The frontend can make requests to the backend, but the nuxtjs-auth module is not working properly: after a succesful login request to the backend, the nuxtjs-auth correctly stores the token as a Bearer token, but it does not attempt to fetch the user (although user.autoFetch
is set to true) and its loggedIn
is set to false.
I tried to manually fetch the user myself, which worked, but loggedIn
was still set to false and the frontend app keeps requiring login, even though the login was successful.
I guess this behavior could be due to subdomains issues. Anyway, I need nuxtjs-auth to behave as it were when the application was running directly on the host's localhost.
Upvotes: 0
Views: 23
Reputation:
I was able to solve the problem by changing the strategy to local
strategy (previously, it was laravelSanctum
strategy from the laravel/Sanctum
provider). I do not know why the issue happened with one strategy but not with another. Takeaway: the bug was not solved, but I found a workaround.
Upvotes: 0