-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] When using https and the user is authenticated when refresh it gets log out #275
Comments
Hey @ezekel, do you have different URL for Laravel which is accessible by your Nuxt server app? Usually it happens if SSR and CSR call different URLs and thus cookies are not available. For more details, you can also change the sanctum module log level to 5 (you can find it in the module docs) and attach output here, it should show why your user gets unauthenticated on page refresh. |
Hi @manchenkoff , can you show me where to edit the sanctum module to level 5 ?
but why if disable ssr it will works fine ? if I refresh it will not redirect to login page if I disable the ssr. Thank you in advance. |
Please, check this link - https://manchenkoff.gitbook.io/nuxt-auth-sanctum/advanced/logging
The difference between SSR and CSR is that your Laravel API is being called from different hosts, which can cause CORS issues and may not be supported by the Laravel app if the SSR host is not included in stateful domain list. You can check more details here - https://manchenkoff.gitbook.io/nuxt-auth-sanctum/usage/cookie-authentication |
Hi @manchenkoff I don't know if I get the correct using logLevel nuxt.config.ts
I tried also to include the api to the stateful domains but no luck
I also have middleware middleware/sanctum_verified.ts
|
I saw this it looks like same problem withe me ssr enable but I tried to put this to sanctum module it doesnt work
|
@ezekel, in your case, this is a problem. Your Laravel API is not reachable from the Nuxt SSR image, probably because your Docker container is named differently. It has nothing to do with the
This is unnecessary because api.* domain is not for frontend callers. |
Hi @manchenkoff,
I noticed an issue when using HTTPS with both Laravel and Nuxt, and setting
ssr: true
in my nuxt.config. After authenticating, if I refresh the Nuxt app, it redirects me to the login page. Additionally, if I try to directly access the URLhttps://larabells.local/dashboard
in the browser, it also redirects me to the login page.Note:
Disabling the ssr works fine
I am using frankenphp laravell 11 and nuxt3 and caddy and docker
.env
NUXT_PUBLIC_SANCTUM_BASE_URL=https://api.larabells.local
nuxt.config.ts
login.vue
dashboard.vue
see my video
nuxt-auth-1.mp4
Thank you in advance
The text was updated successfully, but these errors were encountered: