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

TantraGyan's avatar

Laravel API authentication

I am implementing API authentication in Laravel. My routes.php file looks something like :

Route::group([
            'middleware' => ['api', 'auth:api'],
        ], function () {

            Route::post('complaint', [
                'as'   => 'store.customer.complaint',
                'uses' => 'Api\Customer\ComplaintController@store',
            ]);

        });

But if I see it through Postman, it shows that it is redirecting me to login page. Is it that Postman's request is not taken as ajax request ?

0 likes
1 reply
MC0212's avatar

You need to set the header with Accept: application/json.

Please or to participate in this conversation.