Axios CORS I'm trying to reach from vue to an API (lichess.org's APIs) through axios (from localhost, xampp + apache), but CORS is not having any of it. Is there a way
I've tried this and many variations of it.
const axiosInstance = axios.create({
headers: {
"Access-Control-Allow-Origin": "*",
"Content-Type":"application/json",
"X-Requested-With":"XMLHttpRequest",
}
});
axiosInstance
.get('https://lichess.org/api/games/user/' + this.account + '?max=3/', {
crossDomain: true,
accepts: "application/json",
withCredentials: false,
})
.then(response => {
console.log(response)
})
And also this, just raw
axios.get('https://lichess.org/api/games/user/' + this.account + '?max=3/')
.then(response => {
console.log(response)
})
I had to comment
// window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
in the bootstrapp js
and then this worked
axios.get('https://lichess.org/api/games/user/' + this.account + '?max=3/')
.then(response => {
console.log(response)
})
Please sign in or create an account to participate in this conversation.