Consulting it with AI its telling me that all the routes that are secured by Sanctum should be excluded in VerifyCSRFToken.php. Really?
Problem with Laravel Sanctum and CSRF token mismatch. Laravel is rewriting correct cookie
I'm doing login with Laravel Sanctum cookies.
TLDR: Laravel is trying to rewrite my correctly generated and set xsrf-token cookie with another value.
-
I will call
/sanctum/csrf-cookiewhich will returns to meSet cookie: XSRF-TOKEN=eyJpdiI6ImZhQlJiYU5TRlhjbS9vRGRNYlVCMHc9PSIsInZhbHVlIjoiYTlqR1R0Q2Q1OXh4VTBmRzFlcFpULzFrWjlCZXRJQUpRb25WbTBtd3lqWUxqME45TmVNbFB3a01WRzJaR1M4V3ZpekExOVpnbDMva2svZ2M3UExIMGZ4bWg2SXBLWjdCL3NIaXZkdEdNNDI5Q1ZJS3lQaGZqWVZlV0kzVmVOWDYiLCJtYWMiOiJjNmM1ZGJlOTA5MWIzMWMyOWFkMDhkNGMyYjQ3N2MxZjE3ZGU2YzRmMjM2M2Y4MDIwMDQ0Y2M1NDdjZDQxOGNhIiwidGFnIjoiIn0= -
I will then use this in headers as
x-xsrf-cookie: eyJpdiI6ImZhQlJiYU..... I will correctly log in. I can make other requests as logged in user. Everything is working.
But Laravel in every request (when I log in, when I make subsequent requests) returns Set Cookie: XSRF-TOKEN=UL5o7xLGYMIoP2yiouyh9leqv1CDMsZUkF9KbXKo and is trying to rewrite my correctly set cookie.
Basically I should keep forever that LONG token that I got at /sanctum/csrf-cookie but Laravel is trying to rewrite it with some short token every time I do some request.
Please or to participate in this conversation.