如何通过参数禁用对路由的csrf保护? [英] How to disable csrf protection for a route with parameter?
本文介绍了如何通过参数禁用对路由的csrf保护?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里有一条路线:
Route::post('user/{id}/update','UserController@update');
Route::post('user/{id}/update','UserController@update');
我想为此禁用csrf保护,但是我不知道如何将其uri添加到except
数组中.
I want to disable csrf protection for it, but i don't know how to add its uri into except
array.
推荐答案
您可以在App/Http/Middleware
protected $except = [
'user/*',
];
或者您可以在路由文件上将其禁用
or you can disable it on route file
Route::post('user/{id}/update', [
'uses' => 'UserController@update',
'nocsrf' => true,
]);
这篇关于如何通过参数禁用对路由的csrf保护?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文