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

510
Visualizações
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 Respostas
Responde à pergunta

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 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