In my project I use Fortify for login, registration, password reset and Sanctum which help me with api Authentication.
All Fortify routes work fine(login, password confirmation routes).
But after successfully login, when I want use protected route in api routes file laravel return me:
Message : unauthenticated
My route has included :
Route::middleware('auth:sanctum')
P.s. I use Postman
Where is my fault? What should I do?
I found a solution.
My query included all cookies and a token. In my inquiries, I had to add header:
Origin : 127.0.0.1:8000
Because in
vendor\laravel\sanctum\src\Http\Middleware\EnsureFrontendRequestsAreStateful.php
I reed this:
$domain = $request->headers->get('referer') ?: $request->headers->get('origin');