I have tried these three approaches:
req.headers['x-forwarded-for'] || '').split(',')[0]
req.client.remoteAddress
req.ip (with app.enable('trust proxy'))
But I always get ::1
as a result (on localhost). Other solutions also return ::1
.
I am trying to obtain a real user IP, e.g. 148.62.52.2
. How can I get that?