Answer the question
In order to leave comments, you need to log in
How to get rid of CSRF token not found error in laravel?
I have a backend project using laravel and a react frontend and I have such a problem when I did this command php artisan preset react
. I looked in resources/assets/js/bootstrap.js and there axios should connect
let token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question