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

718
Visualizações
Trying to make a GET request from localhost:8080 to localhost:3000 but I get a cors error, and installing cors on my node.js server doesn't fix it

So I'm trying to make an axios GET request to my Node.js/Express.js localhost:3000 server from my front-end app on localhost:8080 and I understand why I am getting a CORS error. What I don't understand is why after I installed the cors npm package and used it as middleware on my Node.js/Express.js back-end, I still get the CORS error.

I did this inside the app.js file

var cors = require('cors');
app.use(cors());

Then I still get the following error when I try to make a GET request from my front-end:



Access to XMLHttpRequest at 'http://localhost:3000/images' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Shouldn't me using the cors package solve this problem?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have to allow cors to receive that origin. There's a good good video about this. But adding the parameter origin to the cors() middleware should solve it.

var cors = require('cors');
app.use(cors({
    origin: "http://localhost:8000"
}));
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