Vignesh G
Vignesh G

Reputation: 21

How to get client public ip from api request in node js ?

Is there any possible way to get client public ip from api request in node js ?

From request we can get only local ip ....

Upvotes: 2

Views: 836

Answers (1)

Xin
Xin

Reputation: 36490

In nodejs http callback:

request.socket.remoteAddress

if you have a load balancer environment:

(req.headers['x-forwarded-for'] || '').split(',')[0] || req.socket.remoteAddress

Upvotes: 1

Related Questions