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

116
Visualizações
CORS Issue when I send XMLHttpRequest

Chrome Warn:

i try to send a http request to extern Rest API but i steel have an use with the CORS Policy.

i deactivated the Chrome CORS Policy in Chrome, in this window everything working fine but in the Normal Chrome Window i become this Error:

Access to XMLHttpRequest at 'https:///search/fi' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'https://*.de' that is not equal to the supplied origin.

hier is My Code:

<body>
  <h1>Tes Request</h1>
  <script>
  window.addEventListener("load", () => test(), false);

async function test() {
    
        return new Promise(
            resolve => {
                var req = new XMLHttpRequest();
                req.open('POST','https://Test/v1.0/', true);
                req.setRequestHeader("Authorization", "Basic " + btoa('Test'+":"+'Test'));
                req.setRequestHeader('Accept', 'application/json');
                req.setRequestHeader('Content-type', 'application/ecmascript');
                req.setRequestHeader('Access-Control-Allow-Methods','*');
                req.setRequestHeader('Access-Control-Allow-Origin', 'https://Test');
                req.onreadystatechange = function() {
                    if (this.readyState === 4) {
                        req.onreadystatechange = null;
                        if (this.status === 200) {
                            var results = JSON.parse(this.response).value;

                            resolve(results);
                        }
                        else {
                            alert(Error);
                        }
                    }
                };
        var data = `
        {
    "search": {
    "firma": {
    "ustid": "Test"
    }
    },
    "config": {
     "page":1   
    }
    }
    `;      req.withCredentials = true;
            req.send(data);
            });
    }

  </script>
</body>





Access-Control-Allow-Origin: https://app.neugeschaeft.de
Access-Control-Allow-Headers: Content-Type, Authorization, Set-Cookie, Cache-Control
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS
Access-Control-Allow-Credentials: true

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

0

Can you check the browser's debug console and inspect the Network activity to see your request. Check that you have the origin in the request set to whatever the origin needs to be. The response needs to then contain Access-Control-Allow-Origin indicating that the origin is allowed to access the resource.

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