Search code examples
phplaravellaravel-sanctum

Laravel Sanctum: Route [login] not defined


I am trying to get the current user in my laravel vue application. And whenever I trie to get it i am getting this error:

Symfony\Component\Routing\Exception\RouteNotFoundException:

  • Route [login] not defined.

This is what I am sending in postman:

this is what I send in postman

routes\api.php

Route::middleware('auth:sanctum')->get('/user', function (Request $request) { 
    return $request->user();
});

Solution

  • Add new config at headers

    "Accept" => "application/json"
    

    Laravel will check the configuration for "Accept", it will return the Web Page or HTML if no value is set at "Accept" by default.