Answer the question
In order to leave comments, you need to log in
Why does Laravel Passport work so weird?
I made a vue application and installed Laravel Passport access_token
, but for some reason, when I send a request with it, it gives a 401 error. After some googling, I found out that if you add to route
'middleware' => 'auth:api'
, it gives a normal result, but the paths stop working if the user is not authorized (cap)
After some more googling and even searching beyond the first page of Google !! I found out that if you add this code to the api controller:
public function __construct()
{
\Auth::shouldUse('api');
}
api/*
laravel does not use the 'api' defender by default and can this be fixed somehow?
Answer the question
In order to leave comments, you need to log in
It is not always necessary to validate tokens, for example for public information. In fact, you can send all routes to one global middleware auth: api and you will be happy
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question