I recently upgraded my Laravel app from 5.6 to 5.8 and my Passport api does not work anymore.
The 'oauth/token' call works perfectly and I get my access_token as before. Then after, when using the usual call:
$response = $http_client->request('GET', 'api/test', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $access_token,
],
]);
to a very basic protected route:
Route::middleware('auth:api')->get('test', function () {
return ['test' => 'test'];
});
I never get the expected response. Whatever I put inside the route function, I always get an empty 200 response.
This same route without the auth:api middleware works fine by the way:
Route::get('test', function () {
return ['test' => 'test'];
});
It seems that the api:auth middleware does not work anymore and I really don't know why.
My API used to work perfectly before the upgrade. I really don't know what happened.
return response()->json(['test' => 'test']);
? – Tarasovych