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

192
Vistas
How can I detect the IP address of a browser in Express?

This is not a duplicate of this SO post. That method does not work for me. The output is shown below. I am running a local node server on my MacBook and using chrome to test. I get this output.

undefined | ::1

I am connected to the network and can verify that my browser does have an IP address using zshell on Mac which is actually ( I have hidden the last 3 digits for this post):

100.64.98.xxx

However from my server I do not get a reading.

// derived from SO Post above
function getIP(app) {
  app.use((req, res, next) => {
    const ip1 = req.headers['x-forwarded-for'];
    const ip2 = req.socket.remoteAddress;
    const ip =  ip1 || ip2;

    // undefined | ::1
    console.log(ip1 + ' | ' + ip2);
    next();
  });
}

Sometimes the ordering of middleware seems to effect things, and I'm not sure if this might be the case here.

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