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

125
Visualizações
Access to XMLHttpRequest at...... has been blocked by CORS policy

I know there are many responses about this issue but in my case I am running the server and the client side, I have changed the Access-Control-Allow-Origin in my header but still...

I have added the setHeader in my API response but I am still getting the same error. My app.post() is the next:

app.post("/api/todo", (req, res) => {
        Todos.create( req.body)
            .then(doc => {
                res.header("Access-Control-Allow-Origin", "*")
                res.status(200).json(doc);
            })
            .catch(() => {
                res.status(500).json({error: "Could not CREATE the Document"});
            })

I did the same one for a GET request and it worked, as I was facing the same problem before. In this case, with POST request, even though I added that line of code changing the response header I still get the same error.

Could anyone help ?

about 4 years ago · Juan Pablo Isaza
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