laravel 5.8.7 页面已过期 (419)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/55327542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:18:31  来源:igfitidea点击:

laravel 5.8.7 Page expired (419)

phplaravellaravel-5

提问by Omar Saleem

I am submitting a POST request from form and it shows 419 | page expired.

我正在从表单提交 POST 请求,它显示 419 | 页面已过期。

Blade.php:

刀片.php:

<form action="<?php echo action('TestsController@store'); ?>" method="post">

Route:

路线:

Route::resource('tests', 'TestsController');

Controller:

控制器:

public function store(Request $request) {
        echo "something something";
}

回答by Levente Otta

Laravel has built-in CSRF protection. Check out the official documentacion.

Laravel 具有内置的 CSRF 保护。查看官方文档。

Add @csrfto you form.

添加@csrf到您的表单中。

<form action="<?php echo action('TestsController@store'); ?>" method="post">
    @csrf
</form>

回答by Nikolay

As Levente said, first try by putting the @csrf in the form. If that doesn't work, see this thread. It is a duplicate of this issue.

正如 Levente 所说,首先尝试将 @csrf 放入表单中。如果这不起作用,请参阅此线程。它是此问题的副本。

回答by Shahadat Sunny

In my case, I have solved the problem by setting SSL for my domain. I've tried all the solution, but they didn't work. Then I set the SSL for the domain and it solved the problem.

就我而言,我通过为我的域设置 SSL 解决了这个问题。我已经尝试了所有的解决方案,但没有奏效。然后我为域设置了 SSL 并解决了问题。