Closed briansmith7 closed 8 months ago
Hey @briansmith7, are you using SSR or CSR mode in production? and which Nuxt version is there?
@manchenkoff it looks like you are right, this is caused by SSR.
I added the following to my nuxt.config.ts
and this seems to have resolved the issue:
routeRules: {
'/app/**': { ssr: false },
}
Many thanks for you quick response!
No problem @briansmith7, but this is a bug if it works like that. The module is supposed to work in both modes, so I will reopen it to double-check the correctness of the behavior.
@manchenkoff Sure! Let me know if you need any inputs on my config to help you reproduce this
@manchenkoff Sure! Let me know if you need any inputs on my config to help you reproduce this
Nuxt version would help 👍 It might be related to the order of initializing or speed of loading, I'll check on the same version with yours.
I'm using 3.8.0
I'm having the same issue, was actually going to open an issue for this today.
@manchenkoff it looks like you are right, this is caused by SSR.
I added the following to my
nuxt.config.ts
and this seems to have resolved the issue:routeRules: { '/app/**': { ssr: false }, }
Many thanks for you quick response!
So is the solution to have the /app/
in it's own directory without SSR? and the rest of the auth pages in another directory with SSR?
In my case all of the sanctum:auth
protected pages are under /app/**
, login and signup are in the root directory, other pages without middleware (blog, etc) are in their own directories
I will check that behavior, meanwhile you can check if v0.0.11
works better, if so, I would be almost sure about the problem.
I tried v0.0.11
but experienced the same bug when SSR is enabled. Disabling SSR for sanctum:auth
routes also fixed the issue
I'm using latest version v0.1.2
now and am not having this issue anymore.
I'm closing this issue since it is always related to the backend configuration when CSR / SSR works differently, please double-check everything in the checklist here, and try checking out these issues: #34, #57.
P.S.
Feel free to reopen this issue with more details (now I have a predefined Bug template), but usually the difference in domains you are using while sending a request from Nuxt CSR / SSR to Laravel.
I'm experiencing a strange issue when using v0.1.2 of the package:
When an authenticated user refreshes the sanctum:auth protected page or opens it in a new tab - they are immediately redirected to login page, and a few seconds later redirected to onGuestOnly value (i.e. home page) and at this point I see that useSanctumUser is loaded and user is authenticated.
Strangely, I'm only experiencing this in production, but not in local development environment. Reproducing the same steps locally opens the sanctum:auth protected page immediately, without redirecting to login & home.
It seems that middleware rules are evaluated before useSanctumUser variable is initialized, which happens only after a series of redirects.
I would appreciate any suggestions on how to debug what's causing this.