Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 627
Omar Sanchez Avatar asked Dec 18 '22 18:12

Omar Sanchez


1 Answers

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

.

like image 68
Thamer Avatar answered Dec 20 '22 17:12

Thamer