我已經部署了一個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