Laravel 419 error on POST request via POSTMAN
It may be because you are not sending your csrf token with the form data.
In laravel it is mandatory to send the csrf token on every request.
If you don't want to send then mention you method name in the app/http/middleware/VerifyCsrfToken.php
file.
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
protected $addHttpCookie = true;
protected $except = [
'auth/facebook/callback',
'auth/google/callback',
];
}
you need to provide CSRF token with the request you send in that case you need a CSRF token.
Generating CSRF token on web.php
Route::get('/token', function () {
return csrf_token();
});
Sending a request with token | PUT FOLLOWING ON HEADERS |token should be change on each request
(KEY) (VALUE)
X-CSRF-TOKEN MGpzhSLdVWdB7ddQSR8B6iu3A89A6LW7UPT0zmO2
if using postman on headers add
(KEY) (VALUE)
X-CSRF-TOKEN yvthwsztyeQkAPzeQ5gHgTvlyxHfsAfE
you can found VALUE by add
public function index()
{
return csrf_token();
}
and send GET on your route name then you will get VALUE of csrf