Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Diana725's avatar

Route [login] not found Error

When I login using a login form or google auth from my react frontend, the api call is successful and I can access my dashboard. The problem is, from here, every route under auth:sanctum returns a 401 Unauthorized error, with the log Route [login] not found. This is happening even when I use postman. I have set the session domain and sanctum stateful domain as the base url for my website, and my auth.php file has;'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ],

     'api' => [
    'driver' => 'sanctum',
    'provider' => 'users',
    ],
],...my routes outside auth:sanctum are correctly being reached, so cors cannot be the issue. Why aren't my sanctum protected routes working?
0 likes
4 replies
Diana725's avatar

Not really, where should I set that? I'm using laravel 11, so there are some files like Kernel.php that have been excluded in this version.

jayandholariya's avatar

@diana725 For API requests, make sure to include the following headers:

Accept: application/json  
Content-Type: application/json

Also, ensure that you're sending the Authorization token in the request headers.


If you're referring to a Bearer token, you might want to specify it like this:

Also, ensure you're including the Authorization header in the following format: Authorization: Bearer your-token-here

jayandholariya's avatar

@JussiMannisto If you feel the answer wasn't helpful, you're welcome to provide your own response. The goal is to help, not to criticize others for trying.

Please or to participate in this conversation.