I am trying to read an xml file on web server with axios api call. If I copy the xml file URL on a web browser, it opens xml contents. But if I use axio.get to call that URL, I get "Network Error", "CORS Missing Allow Origin". Below is my code:
const url="https://mydomain/folder/myxmlfile.xml";
await axios
.get(url, {
withCredentials: false,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,PUT,POST,DELETE,PATCH,OPTIONS",
"Content-Type": "application/xml; charset=utf-8",
},
})
.then((response) => console.log(response.data))
.catch((err) => console.log(err));
What am I missing here? Please advise! Thanks.