larvel -5重定向到/home登录后点击浏览器返回


Laravel-5 redirecting to /home after login on click browser back

我读了这个:larvel -5登录后重定向到/home

在AuthController中我设置了

protected $redirectPath = '/user/info';

,登录后进入这个页面。但是当点击浏览器后退按钮时,由于某些原因它会转到/home url。

为什么?上一页应为登录页。

修复了这个问题:

Route::get('/home', function () {
    // fix after log in when user clicks back - it wants to redirect to not existing home page
    return redirect('/my-existing-page');
});

您是否使用默认的中间件RedirectIfAuthenticated.php?如果是这样,这就是重定向您的东西—它检查您是否经过身份验证(因为您刚刚登录)并重定向到"/home"。无论出于何种原因,"/home"路径在那里是硬编码的。