Laravel Specify CSRF token in Header
To solve this issue you can specify the CSRF token before performing the ajax. You can specify the CSRF token using the X-CSRF-TOKEN header and then pass the token itself using the "csrf_token()" helper function.
$.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } });
window.axios = require('axios'); window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
<meta name="csrf-token" content="{{ csrf_token() }}">
Leave a reply