When I try to use these requests:
POST /api/products
or
PUT /api/products/:id
I am getting the following error:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined. in file /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 429
#1 /Applications/MAMP/htdocs/laravel-sanctum-api/app/Http/Middleware/Authenticate.php(18): route('login')
#2 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(83): App\Http\Middleware\Authenticate->redirectTo(Object(Illuminate\Http\Request))
#3 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(68): Illuminate\Auth\Middleware\Authenticate->unauthenticated(Object(Illuminate\Http\Request), Array)
#4 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(42): Illuminate\Auth\Middleware\Authenticate->authenticate(Object(Illuminate\Http\Request), Array)
#5 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Auth\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure), 'sanctum')
#6 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/sanctum/src/Http/Middleware/EnsureFrontendRequestsAreStateful.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#7 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful->Laravel\Sanctum\Http\Middleware\{closure}(Object(Illuminate\Http\Request))
#8 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#9 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/sanctum/src/Http/Middleware/EnsureFrontendRequestsAreStateful.php(34): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#10 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful->handle(Object(Illuminate\Http\Request), Object(Closure))
#11 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#12 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#13 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#14 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#15 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#16 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#17 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#18 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#19 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#20 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#21 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#22 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/fruitcake/laravel-cors/src/HandleCors.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#32 /Applications/MAMP/htdocs/laravel-sanctum-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#33 /Applications/MAMP/htdocs/laravel-sanctum-api/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#34 /Applications/MAMP/htdocs/laravel-sanctum-api/server.php(21): require_once('/Applications/M...')
#35 {main}
I am using the token which I have got via login.
For example in header token 2|LIpDVDG2Ry9rJMlevY6wAsQYiWxl1Tm9MdSc****
Please help.