Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda