tell me which route you are hitting send me endpoint
Laravel Sanctum SPA Authentication not working in Api routes
I am using Laravel Sacntum Laravel's built-in cookie based session authentication to make some api's. how ever i noticed the auth:sanctum middleware works when we call it inside the web routes but it wont run properly in the api routes. sending token not available message.
//Web.php routes
Route::middleware('auth:sanctum')->get('stats', StatController::class); - works
//Api.php routes
Route::middleware('auth:sanctum')->get('stats', StatController::class); doesnt work
I added this part too the boostrap/app.php as well
$middleware->statefulApi();
Is there anything else to check . thanks
@JussiMannisto Sure i made silly mistake i just had my env file
#Sanctum configuration SANCTUM_STATEFUL_DOMAINS=localhost
I set it to the my front end domain+port
SANCTUM_STATEFUL_DOMAINS=localhost:5173
then it worked . without that my requests was not stateful
Please or to participate in this conversation.