Hi all,
I'm new to Laravel and wanted to use different middleware groups for the front-end and API. For now I'm using the groups 'web' and 'api'.
Now I would like to apply the 'api' middleware group to my API, but it always seem to apply the 'web' middleware.
This is what I have in my routes:
Route::group(['middleware'=>'api'], function(){
Route::resource('api/users', 'UserController');
});
These are my middleware groups for now:
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class,
\App\Http\Middleware\Authenticate::class,
],
'api' => [
//
],
];
Visiting /api/users still applies the 'web' middleware. I'm noticing that VerifyCsrf and Authenticate are active.
Am I missing something?