laravel route:any 页面因不活动而过期
laravel route:any page expired to inactivity
我在 laravel 5.5 中使用任何一条路线:
Route::any('/', 'HomeController@index')->name('homepage');
路由应该是 GET 路由,但由于第三方提供商使用 POST 重定向,我不得不将其更改为任何;
问题是当第三方(post)进行重定向时,我得到:
The page has expired due to inactivity.
Please refresh and try again.
这是因为 {{ csrf_field() }}
即使收到 POST 请求,我如何传递 csrf_field 并使该路由充当 GET 路由?
Note: Do not disable CSRF protection unless you know what you are doing. I only suggest this because it appears they are not actually POSTing any data to the application on this route.
您可以通过将 URI 添加到 VerifyCsrfToken 中间件中的 $except 数组来从 CSRF 保护中排除 URI:
https://laravel.com/docs/5.6/csrf#csrf-excluding-uris
protected $except = [
'/',
];
只需在表单标签内添加 csrf()。
我在 laravel 5.5 中使用任何一条路线:
Route::any('/', 'HomeController@index')->name('homepage');
路由应该是 GET 路由,但由于第三方提供商使用 POST 重定向,我不得不将其更改为任何;
问题是当第三方(post)进行重定向时,我得到:
The page has expired due to inactivity.
Please refresh and try again.
这是因为 {{ csrf_field() }}
即使收到 POST 请求,我如何传递 csrf_field 并使该路由充当 GET 路由?
Note: Do not disable CSRF protection unless you know what you are doing. I only suggest this because it appears they are not actually POSTing any data to the application on this route.
您可以通过将 URI 添加到 VerifyCsrfToken 中间件中的 $except 数组来从 CSRF 保护中排除 URI:
https://laravel.com/docs/5.6/csrf#csrf-excluding-uris
protected $except = [
'/',
];
只需在表单标签内添加 csrf()。