1

I have vue app & backend laravel , for auth use SPA Authentication

Everything is fine in localhost but in server have some issue

I send login request to sanctum/csrf-cookie then /login and return 200 and logged but when redirect to dashboard get error :

CSRF token mismatch.

this issue only in google chorme but in firefox works fine

I have two sub domain : app.mydomain.com and api.mydomain.com

SANCTUM_STATEFUL_DOMAINS=app.mydoamin.com
SESSION_DOMAIN=.mydoamin.com

also in vue app :

window.axios.defaults.withCredentials = true

my cros settings: 'paths' => ['api/*', 'sanctum/csrf-cookie','login-user'],

'allowed_methods' => ['*'],

'allowed_origins' => ['*'],

'allowed_origins_patterns' => [],

'allowed_headers' => ['*'],

'exposed_headers' => [],

'max_age' => 0,

'supports_credentials' => true,
1
  • API routes don't load the session so don't know the correct CSRF token. Commented Jun 4, 2021 at 8:25

1 Answer 1

0

What are your settings in config/sanctum.php? Set session_domain to .localhost in the .env file This resolved similar issue for me.

Sign up to request clarification or add additional context in comments.

2 Comments

in localhost works fine I mean in webserver not working
@lock laravel includes webserver in its framework. is php artisan serve working for you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.