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

127
Visualizações
Orgchart js error : No 'Access-Control-Allow-Origin' header is present on the requested resource

I am writing an organization chart creation program with orgchart.js and simple php. (Without using any framework). But it gives me the following error:

Access to XMLHttpRequest at 'https://uk-s-balkangraph.azurewebsites.net/api/OrgChartJS' from origin 'https://xxxxxx.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I also put the following code in the .htaccess file, but it did not work:

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

I also put the following code in the index.php file, but it did not work:

header("Access-Control-Allow-Origin: *");

I am an amateur programmer. please guide me

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is multiple ways to do it :

  1. Set header instead of add

Instead of using header add you can use header set

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

And it's what I will do for next propositions.

  1. Use apache/nginx virtual host configuration

In VirtualHost config (in apache), you can use :

<VirtualHost myhost:80>
   Header set Access-Control-Allow-Origin "*"
</VirtualHost>
  1. More use PHP header :
header('Access-Control-Allow-Headers: Access-Control-Allow-Origin, Content-Type');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
about 4 years ago · Juan Pablo Isaza Relatório
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