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

715
Vistas
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 Respuestas
Responde la pregunta

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