在laravel 5.4中禁用某些路由的csrf令牌? 不工作[重复]

This question already has an answer here:

I am making an API for my website, API will be used to get, post, delete some data, but to post, csrf token is needed which cannot be generated from third party websites, so I have to disable csrf token for some routes. In documentation it says to add following in verifycsrftoken.php:

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

But this is not working in laravel 5.4. Here is my sample route:

Route::post('leads/{id}', ['as'=>'leads']);

Any help would be appreciated.

</div>

The code you posted should work.

As you said in your comment, the error is MethodNotAllowedHttpException. That error in thrown when you try to visit a url with the wrong type. In order to send the form via POST, you will need to indicate in the form tag

<form method="POST" action="{{ url('leads/'.$lead->id) }}>

and also add the csrfToken inside the form

{!! csrf_field() !!}