I am facing an issue with my Laravel/Vue with Sanctum setup. The problem is simple:
When I send a token request and log in the user, the server responds with a new token. However, Axios is adding this new token along with an additional token that is always the same and expired.
Here is the code snippet:
await APIClient.get("/sanctum/csrf-cookie")
return APIClient.post("/api/user/login", payload);
Upon inspecting DevTools/Network tab:
- csrf-cookie request =>
response-headers
contains the validXSRF-TOKEN
- login request =>
request-headers
,SET-COOKIE
property containsXSRF-TOKEN
(old expired value);
laravel_session
;
XSRF-TOKEN
(new valid value)
The issue lies with the presence of the old expired value. I have not included any code in my project that adds this token.
Below is my Axios client configuration:
const APIClient = axios.create({
baseURL: constants.PATHS.url,
withCredentials: true, // necessary for handling the CSRF token
});
Any assistance you can provide would be greatly appreciated.