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

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

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