Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Binay7587's avatar

Middleware auth:sanctum not working in Laravel Module route

I have used nWidart/laravel-modules package then I installed 'Laravel/sanctum' through composer and published the vendor and migrated migrations and used Laravel\Sanctum\HasApiTokens on Entitites/User. There is an api route file on user module and 'auth:sanctum' middleware is used on '/api/me' route. It should send Unauthenticated JSON response when there is no token, but when i hit this api without token, its showing login page even if i had used Accept: application/json as header.

Also im not able to hit this api even if i have sent the current token.

This is my api route file:

Image of Route File

This is the response i'm getting when I hit that api. Response Image

0 likes
0 replies

Please or to participate in this conversation.