Shawdow's avatar

what is the use api middleware in laravel 8

I am using default api middleware in laravel.can any one tell me what is the use of api middleware?

Route::group(['middleware' => ['api']], function(){
    Route::get('get-list-users',[App\Http\Controllers\UserListApiController::class, 'list_of_users']);
});
0 likes
6 replies
Shawdow's avatar

@Nakov thank you .can we avoid api routes accessed by using a url bar?

Shawdow's avatar

@Nakov after adding token based authentication users can hit url from the browser.suppose if they hit from the browser url bar it says "token is required" message.so this how we will protect the routes from browser from your point view?

Nakov's avatar

@Shawdow no it will redirect them to a login page, as that endpoint will be protected. Why would anyone know your API endpoints is a different kind of question, but I really don't have a clue on what you are doing to give you better answer. So please read about it, or watch some of the thousands of videos about Rest API with Laravel.

Here is one: https://www.youtube.com/watch?v=MT-GJQIY3EU&ab_channel=TraversyMedia

Please or to participate in this conversation.