by bqc on 8/20/24, 1:36 PM with 12 comments
I’m developing a Node.js application and need to obtain the public IP address of the users accessing the app. What are the most reliable methods or libraries to achieve this? Are there any security considerations I should be aware of when implementing this feature?
by pavel_lishin on 8/20/24, 2:33 PM
by beardyw on 8/20/24, 2:57 PM
Unless they use a proxy every internet interaction contains the originators ip address. It's how you are able to respond to it.
Assuming you are developing node.js on a server.
by solardev on 8/20/24, 2:00 PM
That's more of a function of your web server's access logs (or your hosted service's analytics, if in the cloud) than Node.js itself.
by nov21b on 8/20/24, 2:41 PM
req.ip, but also look at the x-forwarded-for header if you are using a proxy server. This header can have multiple ip's when you have say nginx terminate ssl and use cloudflare.
by pestatije on 8/20/24, 2:32 PM
are the users using http/https to access the app?