我收到的CSRF令牌不匹配,但这不是潜在的问题。当我向页面添加异常时,我收到500错误。
我发现这是由创建会话的问题引起的。
当我服务时,一切正常。当我把它投入生产时,它无法创建会话。
之前有没有人遇到过这个问题?
我收到的错误:
1/1
TokenMismatchException in VerifyCsrfToken.php line 68:
in VerifyCsrfToken.php line 68
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53
然后我将登录路由添加到CSRF例外,我收到500错误。
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
'/login/',
];
}
Google Chrome错误消息:
This page isn’t working
'address' is currently unable to handle this request.
HTTP ERROR 500
答案 0 :(得分:0)
运行CentOS 7.0和SElinux阻止了apache用户写入存储。即使您为此目录设置了chmod 777,也不允许您写入存储目录。
存储文件夹是存储会话的位置,因此它会引发csrf令牌不匹配,因为它与关闭的会话变量无法比较。
我想强调,这是一个配置问题,而不是一个laravel问题。我在互联网上进行了广泛的搜索,这最终解决了我的问题。
setenforce 0
这应该允许写入,但是你已经关闭了服务器范围内增加的安全性。那很糟。转回SELinux
setenforce 1
然后最后使用SELinux允许使用项目根目录中的此命令写入文件。
chcon -R -t httpd_sys_rw_content_t storage
我要感谢评论部分的所有人,您的提问线让我走上正确的解决方案!