1

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 Answer 1

2

You could add an except property in your middleware

Route::group(['middleware' => ['api'], 'except' => 'Login'], function () {
    // Your Routes
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.