1$.ajaxSetup({
2 headers: {
3 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
4 }
5});
1<meta name="csrf-token" content="{{ csrf_token() }}" />
2
3<script type="text/javascript">
4$.ajaxSetup({
5 headers: {
6 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
7 }
8});
9</script>
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<form method="POST" action="/profile">
2 @csrf
3 <input name="name">
4 <button type="submit">send</button>
5</form>