Ajax LARAVEL 419 POST error Ajax LARAVEL 419 POST error ajax ajax

Ajax LARAVEL 419 POST error


Laravel 419 post error is usually related with api.php and token authorization

Laravel automatically generates a CSRF "token" for each active user session managed by the application. This token is used to verify that the authenticated user is the one actually making the requests to the application.

Add this to your ajax call

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

or you can exclude some URIs in VerifyCSRF token middleware

 protected $except = [        '/route_you_want_to_ignore',        '/route_group/*    ];


419 error happens when you don`t post csrf_token. in your post method you must add this token along other variables.


Had the same problem, regenerating application key helped - php artisan key:generate