Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Where to put my code "Access-Control-Allow-Origin"?

I need to retrieve data from an api but the data is only available in XML. I was told to retrieve the data to display it in HTML via this topic: How to retrieve values from xml file and display in html webpage?

Until I thought I was right, I changed the code with the info I needed and got the famous error in the Google Chrome console: (index):30 Access to XMLHttpRequest at 'xxx' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

So in my index.html file I added this PHP code at the beginning : <?php header('Access-Control-Allow-Origin : *'); ?> (I use the * for the tests only, to publish my code I will set the exact URL).

My page still shows this error, so I'm wondering if it's really on my code that I should put this, or on the recipient's server?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda