79624912

Date: 2025-05-16 09:46:44
Score: 1
Natty:
Report link

Problem resolved here:

https://laracasts.com/discuss/channels/laravel/laravel-sanctum-generates-new-xsrf-token-for-stateful-api-requests

The XSRF token is encrypted and in fact it is the same token.

You cannot and should not disable Laravel's Set Cookie header, which it sends to SPA API requests (for my case with CSRF-protection).

The /sanctum/csrf-cookie is needed in order to be sure that the SPA has a token, because it may not send GET requests when the page loads, as in my case

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: jsssy