Mazzy
Mazzy

Reputation: 14179

Get the ip address of the client making the request in expressjs

I have an application deployed on Azure and I'm trying to get the ip address of the remote client. Unfortunately I get always a value undefined when try to call

req.ip

Do you have any idea to get the ip address?

Upvotes: 1

Views: 4701

Answers (1)

Nicolas Del Valle
Nicolas Del Valle

Reputation: 1484

const remoteAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;

Upvotes: 1

Related Questions