1//In laravel 7. Open file \App\Http\Middleware\VerifyCsrfToken.php
2//Disable for all routes
3
4protected $except = [
5 '*',
6];
7//Disable for some routes
8 protected $except = [
9 'mobile/*',
10 'news/articles',
11];
12//I searched for a long time how to disable CSRF completely,
13//there are many identical examples but they do not help
1<?php
2
3namespace App\Http\Middleware;
4
5use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
6
7class VerifyCsrfToken extends Middleware
8{
9 /**
10 * The URIs that should be excluded from CSRF verification.
11 *
12 * @var array
13 */
14 protected $except = [
15 'stripe/*',
16 'http://example.com/foo/bar',
17 'http://example.com/foo/*',
18 ];
19}