Home > Article > PHP Framework > How to turn off csrf verification in laravel
How to turn off csrf verification in laravel: 1. Open Kernel.php and comment "App\Http\Middleware\VerifyCsrfToken"; 2. Open VerifyCsrfToken.php and specify the URL to be excluded from CSRF verification.
The operating environment of this tutorial: Windows 7 system, Laravel version 5.1, DELL G3 computer.
How to turn off csrf verification in laravel?
Laravel 5.1 Turn off csrf verification:
Description:
Laravel has the CSRF function enabled by default, and sometimes the verification token may not be passed , it needs to be closed.
Method 1 (global shutdown):
Open the file: app\Http\Kernel.php
Put this line Comment out:
'App\Http\Middleware\VerifyCsrfToken'
Method 2 (partially closed):
Modify the app\Http\Middleware\VerifyCsrfToken.php file.
In protected $except = [], specify URLs to exclude from CSRF validation
Example:
protected $except = [ //关掉以api开头的请求 'api/*', //关掉带有.htm的请求 '*.htm*' ];
Related recommendations:The latest five Laravel video tutorial
The above is the detailed content of How to turn off csrf verification in laravel. For more information, please follow other related articles on the PHP Chinese website!