@stesvis What do you mean "logged out"? your API should be accepting a Bearer token... it doesn't rely on you being logged in to the site.
If this is for SPA, please specify.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I am using Passport to protect my APIs, and when I am logged in it's all good, but when I am logged out my API still returns a 200 code instead of 401. The response is the HTML content of my web login page.
How come??
This is the route @mariohbrino :
Route::resource('vehicles', 'Api\VehiclesApiController')->middleware('auth:api');
And I use it from a mobile app.
I think I managed to resolve it tho, by passing this header: Accept: application/json
With it, if i try to consume the endpoint without a token it returns 401 correctly. Without it, it would return the html of my login page (where the Authenticate middleware redirects me).
Please or to participate in this conversation.