1
votes

I am running Laravel 5.4 and have my API routes setup with an API middleware that verifies an authentication token sent in the headers.

However, I want to avoid, or prevent the api/Login (route that generates the auth token) from being subject to the middleware.

Currently, in my API middleware, before any logic happens I have:

if(strpos($request->getUri(), 'Login')):
    return $next($request);
endif;

I would like to remove checking if the route is the Login route before proceeding with the middleware logic. Is there a native way in Laravel to accomplish the above?

Note: all API routes are protected via an API middleware group which I have created in the Http/Kernel, then added the in the RouteServiceProvider.

1

1 Answers

2
votes

You could add an except property in your middleware

Route::group(['middleware' => ['api'], 'except' => 'Login'], function () {
    // Your Routes
});