我已经部署了一个larabvel应用程序fortrabbit。已部署的应用程序仅用于测试身份验证和中间件('auth'和'guest')的简单应用程序。我已经尝试在localhost的应用程序,身份验证和中间件工作正常。当我在fortrabbit上试用我的应用程序时,身份验证正常运行,但中间件存在问题。我得到在Fortrabbit重定向循环Laravel 5.1
每次我登录到主页时此网页有重定向循环,ERR_TOO_MANY_REDIRECTS
。
routes.php
:
Route::get('/','[email protected]');
Route::group(['middleware' => 'guest'], function() {
Route::get('login','[email protected]');
Route::post('login','[email protected]');
Route::get('register','[email protected]');
Route::post('register','[email protected]ister');
});
Route::group(['middleware' => 'auth'], function() {
Route::get('home','[email protected]');
Route::get('logout','[email protected]');
});
Authenticate.php
的 '权威性' 中间件:
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else{
return redirect()->guest('/login');
}
return $next($request);
}
RedirectIfAuthenticated.php
的 '客人' 中间件:
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
return redirect('home');
}
return $next($request);
}
是否有任何文件/在fortrabbit设置,我必须配置正确运行这个应用程序?
您的认证中间件对我来说很不利。如果guest()这样做,如果没有guest重定向到登录。如果您是不允许客人的页面上的客人,您是否不应该重定向登录?你处于一个无休止的循环中,因为一旦你登录了,你就不再是客人了,所以你会被重定向到'home',这会触发已关闭的'auth'并将你重定向到登录,这会触发重定向你的'guest' ... – sniels
嗨,我认为这是一个会话错误https://github.com/laravel/framework/issues/8172你可以尝试一次干净的安装吗?会场司机在堡兔子里设置了什么? – Gokigooooks