-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
CSRF token mismatch error #108
Comments
Hey @Jonston, most likely, you have misconfigured session domain on Laravel's side. Please check this docs to make sure you have everything set - Nuxt Auth Sanctum - Laravel config. |
Cookies are sent to the server by XSRF-TOKEN and laravel_session. cors are configured correctly in my opinion. config/cors.php config/sanctun.php
.env |
@Jonston Nuxt info:
|
@Jonston |
nuxt.config.ts
package.json
I use SSR i olso take this error in terminal
|
This one is about missing endpoint in your Laravel app, module cannot load the user during initialization. Make sure that this endpoint is defined and you have access to your laravel app from node via localhost. For further investigation I still need more logs and request information as mentioned previously. And let me know if you removed |
I remove SESSION_DOMAIN access to app exists at localhost:80
api/user route exist but it protected 'auth:sanctum' |
That's fine, it is supposed to be secure. I am not sure why you have connection issues between node and laravel, but I assume that it might be the reason why you are getting this weird behavior with authentication and mismatching tokens. Once you provide all logs from the module and request/headers/cookies details from your browser for all requests, I will try to help. |
If I login manually via axios, everything works. Cookies are set, the user logs in and receives the user successfully
|
I also noticed that if I disable the ssr: false option in the configuration, then everything works. I also want to clarify that I use laraver sail wrapper over docker. I have a suspicion that requests sent from the nuxt server do not work correctly with the session |
It should work fine with sail as well, I created breeze-nuxt and breeze-api templates based on this configuration. Please, provide logs from the module by setting |
By the way, @Jonston do you run node in docker as well? |
Hello. Problem during the first login attempt. When using the login method, 2 requests are sent simultaneously to the
sanctum/csrf-token
cookie installation URL andlogin
authorization. Why am I getting the error?"CSRF token mismatch." When I try to log in again, everything works fine. What am I doing wrong?
The text was updated successfully, but these errors were encountered: