Omar Sanchez
Omar Sanchez

Reputation: 165

CSRF in laravel 5.8 with axios and vue

I have a doubt, I'm using Laravel 5.8 and I have a component in Vue that is a simple registration form. When I submit the form via POST method, Laravel doesn't request me the CSRF token, is this a normal behavior? I'm not using the API routes.

I just noticed in the Chrome storage there is a XSRF-TOKEN.

enter image description here

So, how is now working the CSRF validation via ajax?

Upvotes: 4

Views: 4326

Answers (1)

Thamer
Thamer

Reputation: 1954

as mentioned in the laravel5.8 doc

When building JavaScript driven applications, it is convenient to have your JavaScript HTTP library automatically attach the CSRF token to every outgoing request. By default, the resources/js/bootstrap.js file registers the value of the csrf-token meta tag with the Axios HTTP library. If you are not using this library, you will need to manually configure this behavior for your application

for more information check laravel 5.8 csrf doc

.

Upvotes: 11

Related Questions