Laravel - CSRF Protection - Csrf X Csrf Token

In addition to checking for the CSRF token as a POST parameter, the App\Http\Middleware\VerifyCsrfToken middleware will also check for the X-CSRF-TOKEN request header. You could, for example, store the token in an HTML meta tag:


Then, you can instruct a library like jQuery to automatically add the token to all request headers. This provides simple, convenient CSRF protection for your AJAX based applications using legacy JavaScript technology:

        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')