jessicaosouza's avatar

Axios with credentials

I have a laravel app with jetstream+inertia and I am using a few apis to fetch data when logged in and for that I am using axios. I added the following config in resources/js/bootstrap.js so I can perfom axios requests

window.axios = require('axios');
axios.defaults.withCredentials = true;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

I add this because when I was perfoming axios request It was returning this message:

{"message":"Unauthenticated."}

Now It is working just fine in development but the error is still there in production. Any thoughts?

0 likes
1 reply

Please or to participate in this conversation.