Site logo

Archived topic

Error CORS “Access-Control-Allow-Origin

1 reply · Started by timalua on February 9, 2021

Viewing posts 1–2 of 2

----------------------- GOOGLE TRANSLATOR -----------------------------------

Good morning,

i have a problem with .gpx map pages for domains on other languages ​​but on same installation as wordpress

I get this error:

Blocked multi-origin request (cross-origin): the origin matching criterion does not allow the remote resource to be read from https://www.virtualelba.it/elba-sentieri/trekking-nord-sud-elba.gpx. Reason: missing CORS "Access-Control-Allow-Origin" header.

I added the following code in the functions.php file of the generatepress-child theme, but I don't get any results.

--------------------------------------------

add_filter ('allowed_http_origins', 'add_allowed_origins');

function add_allowed_origins ($ origins) {
$ origins [] = 'https://www.virtualelba.com';
$ origins [] = 'https://www.virtualelba.net';
return $ origins;
}

-------------------------------------------

I think it gets overwritten somewhere.

I also tried in "elements" of Generatepress, but I don't think I did it right

Can you tell me where to add it and how?

Thanks Andrea

-------------------------- ITALIANO Buongiorno,

ho un problema con le pagine delle mappe in gpx per domini su altre lingue ma su stessa installazione di wordpress

ricevo questo errore:

Bloccata richiesta multiorigine (cross-origin): il criterio di corrispondenza dell'origine non consente la lettura della risorsa remota da https://www.virtualelba.it/elba-sentieri/trekking-nord-sud-elba.gpx. Motivo: header CORS "Access-Control-Allow-Origin" mancante.

Ho aggiundo il seguente codice nel file functions.php del tema generatepress-child, ma non ottengo nessun risultato.

--------------------------------------------

add_filter( 'allowed_http_origins', 'add_allowed_origins' );

function add_allowed_origins( $origins ) {
$origins[] = 'https://www.virtualelba.com';
$origins[] = 'https://www.virtualelba.net';
return $origins;
}

-------------------------------------------

Credo venga sovrascritto da qualche parte.

ho provato anche in "elementi" di Generatepress, ma non credo di aver fatto nel modo giusto

Sapete dirmi dove aggiungerlo ed il modo?

Grazie Andrea

Hi there,

That code should be added in the function.php of the child theme or using a plugin like Code Snippets.

If this is what you did then it's the right method.

I'm guessing the code itself is not doing what you think it is supposed to do?

The theme itself cannot control this.

If you Google the exact error, there should be lots of suggestions on how this could be fixed.

This archived topic is closed to new replies.