close

[Solved] Ajax LARAVEL 419 POST error

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Ajax LARAVEL 419 POST error in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Ajax LARAVEL 419 POST Error Occurs?

Today I get the following error Ajax LARAVEL 419 POST error in php.

How To Solve Ajax LARAVEL 419 POST Error ?

  1. How To Solve Ajax LARAVEL 419 POST Error ?

    To Solve Ajax LARAVEL 419 POST Error Had the same problem, regenerating application key helped – php artisan key:generate

  2. Ajax LARAVEL 419 POST error

    To Solve Ajax LARAVEL 419 POST Error Had the same problem, regenerating application key helped – php artisan key:generate

Solution 1

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/*
    ];

Solution 2

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

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment