Axios.get fails: Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers


#1

Hello everybody,

at the moment, I am trying to use axios to send a little GET request:

axios.get (process.env.MIX_MATOMO_URL + '/index.php?module=API&method=AjaxOptOut.isTracked&format=json').then ((response) => {
				this.tracked = response.value;
});

This fails with:

Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.

Alright - I added my domain to Matomo’s cors_domains - but without success.

Any help is highly appreciated :slight_smile:


#2

This is a server related issue. As the error says, you are passing X-Requested-With as a header which is not allowed by the server. So, either don’t pass it (if you don’t need it) or configure your server to allow the header.