umerhassan's avatar

CSRF token mismatch Laravel sanctum with vuejs

I have very weird problem. I have one project hosted and main domain is serving real data and one sub domain is for test server you can say.

  • Main: website.com
  • Testing: test.website.com

I have implemented larave sanctum and it was working fine and from no where I start receiving an error that CSRF token mismatch

if I change SANCTUM_STATEFUL_DOMAINS from test.website.com to https://test.website.com then I start receiving error Unauthenticated user.

But the weird thing is it is working fine on local and live server. Only problem in subdomain

0 likes
2 replies
vincent15000's avatar

Set SANCTUM_STATEFUL_DOMAINS to .website.com (with the dot).

Please or to participate in this conversation.