In the html meta
<meta name="_token" content="{{ csrf_token() }}"/>
Laravel is not generating csrf token after adding middlware in the route, I will show 2 examples:
When I add this middleware it does not work, that is, it does not generate csrf_token
Route::group(['prefix' => '/', 'middleware' => ['validateUser']], function () { ... }
When I remove middleware, it works normally
Route::group(['prefix' => '/', 'middleware' => []], function () { ... }
Very strange, I realized this after doing some tests, I need help understanding this: /
ValidateUser code
public function handle($request, Closure $next)
{
if( Session::has('explorer') ) {
if( isset($_SERVER['HTTP_REFERER']) ) {
return redirect($_SERVER['HTTP_REFERER']);
} else {
return redirect('/explorador');
}
} else {
Session::flush();
return $next($request);
}
}