K.33s
K.33s

Reputation: 61

get 419 error when posting from axios to laravel

I have the csrf which it's already attached to the axios header at bootstap.js, I get always this response from server when try to post simple post (they are three pictures below explaining my situation)

axios post from vue file:
axios post from vue file

Route at web.php:
Route at web.php

result 1:
result 1

result 2:
result 2

Upvotes: 1

Views: 1294

Answers (1)

Kenziiee Flavius
Kenziiee Flavius

Reputation: 1949

Try this, it works for me so far but you'll be without CSRF, go to 'App\Http\Middleware\VerifyCsrfToken' then edit the protected variable to this

 protected $except = [
     "/*"
 ];

the '/*' says to exclude CSRF from all routes, although this isn't ideal it should fix the problem, Maybe just exclude those specific routes that are throwing you the error?

e.g. "/specificRoute"

Upvotes: 4

Related Questions