Laravel 5: POST without CSRF checking

后端 未结 4 924
醉梦人生
醉梦人生 2021-01-17 19:07

It seems that Laravel 5 by default applies the CSRF filter to all non-get requests. This is OK for a form POST, but might be a problem to an API that POSTs DELETEs etc.

4条回答
  •  迷失自我
    2021-01-17 19:35

    You can exclude URIs from CSRF by simply adding them to the $except property of the VerifyCsrfToken middleware (app/Http/Middleware/VerifyCsrfToken.php):

    Documentation: http://laravel.com/docs/5.1/routing#csrf-protection

提交回复
热议问题