I searched over the internet for solve this issue. All I saw are other types of error. I use CSRF, my cache isn't the problem and my files had the correct permissions.
The login page is out of the "web" middleware because I don't want to be affected the session timeout on it. I don't know how but if I let the session ends, I mean the timeout, I get the next error message when I try to login in my project
The page has expired due to inactivity. Please refresh and try again.
Just for clarify, if I login before the timeout expire all works fine
In my routes/web.php I have:
Route::get('/', 'LoginController@index')->name('index');
Route::middleware(['web'])->group(function () {
// More routes
}
In my Kernel.php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
Looks like RouteServiceProvider at App/Providers is generating the error. The following function make all the routes use the web middleware:
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
I found that some people make differents functions on this file for differents controllers. I mean, probably make a new middleware and move this route to a new controller could be an option. Unfortunately, I don't found how create a middleware without be affected by a session timeout.