Search code examples
laravelrestlaravel-8laravel-sanctuminsomnia

I need to add basic auth to my sanctum api


I'm using laravel sanctum and I add to middleware to my route:

Route::group(['middleware' => 'auth:sanctum'], function () {
    Route::post('/sms-log',[SmsLogController::class, 'store'] );
});

But insomnia wants me to sign in: insomnia_ss

when I remove middleware from API route working as expected. so how can I add basic auth?


Solution

  • In insomnia add a header so you don't get redirected to the login route, instead you get a "message":" Not authenticated."

    Accept: application/json