How to disable csrf protection for a route with parameter?

て烟熏妆下的殇ゞ 提交于 2019-12-11 01:41:26

问题


there is a route like:

Route::post('user/{id}/update','UserController@update');

I want to disable csrf protection for it, but i don't know how to add its uri into except array.


回答1:


You can add the given code in VerifyCsrfToken file at App/Http/Middleware

protected $except = [
    'user/*',
];

or you can disable it on route file

Route::post('user/{id}/update', [
   'uses' => 'UserController@update',
   'nocsrf' => true,
]);


来源:https://stackoverflow.com/questions/41757431/how-to-disable-csrf-protection-for-a-route-with-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!