1

我的 Laravel 项目在这个链接中

http://localhost/demo/public // laravel project

我有这个外部 HTML 表单

http://localhost/attendance

现在我想将表单中的数据发送到 Laravel 但我收到了这个错误

419 页面已过期

所以在我的 laravel 项目 VerifyCsrfToken 类中我写了这个

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'http://localhost/attendance'
    ];
}

但仍然出现同样的错误

419 页面已过期

4

2 回答 2

2

Laravel 为您解析应用程序的 baseUrl,无需放置完整路径,在您的情况下,中间件应如下所示:

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'attendance/*'
    ];
}
于 2019-06-19T13:48:31.757 回答
1
  • 一种解决方案是将数据作为 GET 请求而不是 POST 请求发送。

  • 一旦你把你的作品放到网上,你就会在浏览器上面临跨站点保护。

  • URI要排除的是接收请求的人,所以http://localhost/demo/public

于 2019-06-19T13:48:12.663 回答