Replies: 1 comment
-
I found a solution to this problem through adding decoding for the header.
Add this method to your middleware App\Http\Middleware\VerifyCsrfToken |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have an API in Laravel and a web application in Angular that must consume this API, the problem I have is that I am implementing authentication using Laravel Sanctum and I have the following error when trying to send a POST request for login:
{message: "CSRF token mismatch.", exception: "Symfony\Component\HttpKernel\Exception\HttpException",…} POST http://xxxxxxxx.test/login 419 (unknown status)
In my code I first make a GET request to
http://xxxxxxx.test/sanctum/csrf-cookie
which is the Sanctum path where the API sets a session cookie (laravel_session) and another one from the CSRF (XSRF-TOKEN) and then if I make the POST request to/login
.The problem is that according to the documentation, the token must be returned in the POST request in an X-XSRF-TOKEN header and according to the documentation, Angular should do it on its own, but checking the Request-Headers from the Chrome inspector, not This header appears to have been submitted. So, I have thought about forwarding it myself, but I have no way to get it since I only get this:
As for the other settings I am almost sure that they are fine, and as for the domains, Laravel is at
http://miweb.test:80
and Angular athttp://app.miweb.test:4200
Beta Was this translation helpful? Give feedback.
All reactions