学习 Laravel 那些坑(三) csrf_token()

laravel 5.5 填写注册信息时遇到错误信息

The page has expired due to inactivity. 
Please refresh and try again

http 状态 419 Authentication Timeout (not in RFC 2616)

这时 url 已跳转到 login,显然登录时有问题;查了下是 csrf_token 的问题;
php - laravel 5.5 The page has expired due to inactivity. Please refresh and try again - Stack Overflow

题主命中的 answer是:

This problem comes from the CSRF token verification which fails. So either you’re not posting one, or you’re posting an incorrect one.

The reason it works for GET is that for a GET route in laravel, there is no CSRF token posted.

You can either post a CSRF token in your form by calling:

 {{ csrf_field() }}

Or exclude your route in app/Http/Middleware/VerifyCsrfToken.php

 protected $except = [
        'your/route'
    ];

试过了,然并卵;不是这种情况;

后来想到 csrf 会不会是.env 里配置的问题,

 APP_URL=localhost

修改为访问的 url,依然并卵;

后又修改 storage 权限,问题解决!

你可能感兴趣的:(学习-laravel)