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

536
Visualizações
how to get client public IP address using javascript or typescript

Could someone please let me know how to get public IP address of the client machine using JavaScript or typescript?

Thanks & Regards, Ajay

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

0

This is the most basic configuration. and its only for learning purposes. please take the time to read and learn about running server with node js. the risks and how to protect.


var express = require("express");

var app = express();

app.get("/", (req, res) => {
  console.log(req.ip);
  res.status(200).json({ userIp: req.ip });
});

var listener = app.listen(8080, function () {
  console.log("Listening on port " + listener.address().port);
});

you need to install express. put this code in the app.js.

after running the server any request to '/' will return json with the user ip.

on local host you will get something like ::1 but if you will upload it to a server you will get the right result.

in this case calling loaclhost:8080/ will return the user's ip.

working example here

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