WdBly Blog

懂事、有趣、保持理智

WdBly Blog

懂事、有趣、保持理智

周维 | Jim

603927378@qq.com

Laravel提交POST请求出现The page has expired due to inactivity. Please refresh and try again.

Laravel项目提交表单错误The page has expired due to inactivity解决方案

出现此问题的原因是Laravel对POST, PUT 或 DELETE类型的路由请求都会检查CSRF令牌(CSRF token),如果此请求不包含令牌会被拒绝。

解决:

可以通过排除路由的方式跳过此验证:

app -> Http -> Middleware -> VerifyCsrfToken.php

在$except中加入你要排除的路由即可

<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; class VerifyCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ 'user/*','article/*','api/*' ]; }