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

244
Visualizações
what is Cors-Policy why it is not allowing me to use content- type in post request of Fecth API in javascript?

it is showing like this when i am running the post request in console

Access to fetch at 'http://dummy.restapiexample.com/api/v1/create' from origin 'http://127.0.0.1:5501' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
tut42.js:57 POST http://dummy.restapiexample.com/api/v1/create net::ERR_FAILED
postData @ tut42.js:57
(anonymous) @ tut42.js:61
tut42.js:57   Uncaught (in promise) TypeError: Failed to fetch
    at postData (tut42.js:57)
    at tut42.js:61
postData @ tut42.js:57
(anonymous) @ tut42.js:61
Promise.then (async)
postData @ tut42.js:58
(anonymous) @ tut42.js:61
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Being a cross domain request the API call seems to be blocked itself can you try adding Access-Control-Allow-Headers individually or you can switch to no-cors mode.

fetch(request, {mode: 'cors'});

For better understanding for CORS kindly check https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS.

And for the different header that you can play in correspondence with Access-Control-Allow-Headers is in the following link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers

Access-Control-Allow-Headers: *
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