Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

527
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!