laravel sanctum Route [login] not defined

Viewed 3594

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. in file C:\Users\Moeme\Documents\School\HsLeiden\Keuzevakken\IKFRAM\sla ticketsystem\ticketsystem\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php on line 444

This is what I am sending in postman:

this is what I send in postman

This is what I have in my routes\api.php

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

I really do not know why it is not working

Thanks for the help

3 Answers

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

I got the same error when making the request only for the postman, add this to the headers

key: Accept

Value: application/jsonenter image description here

  1. Your URL incorrect. Remove "/" before query parameters.

    https://127.0.0.1:8000/api/user?param1=value&param2=value - this for route '/api/user' with query params "param1" and "param2"

  2. You are trying pass headers in a query parameters. Move "Accept" and "Authorization" to "Headers" tab for requests in Postman.

Related