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

504
Vistas
Post Request CORS Error (Access-Control-Allow-Origin) on fetch api even i added access control on my header

I am trying to post some data on a backend server. but when i submit the data i got an error following below: Fetch at 'X' from origin 'localhost:8080' has been blocked by cors. No Access-Control-Allow origin in the header.

Though I have access-control-allow origin on header. The code is given below:

fetch(url, {
  mode: "cors",
  method: "POST",
  headers: {
    "Access-Control-Allow-Origin": "http://localhost:8080",
    "Access-Control-Allow-Credentials": "true",
    "Content-Type": "application/json",
    "API-Key": "xxxxxxxxxxxxxx",
    Accept: "application/json",
  },
  body: JSON.stringify(data),
})
  .then((response) => response.json())
  .then((data) => {
    console.log("Success:", data);
  })
  .catch((error) => {
    console.error("Error:", error);
  });

I have tried no-cors policy but that server doesn't accept no-cors request.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

CORS is filtered and handled server-side. Try adding allowed hosts in the server config, if you have access. What is your back-end framework?

Or you can bypass CORS in chrome using --disable-web-security. Check here.

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