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

187
Visualizações
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 à 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