I have an Azure function written on node.js. How could I retrieved an IP address of a client that called the function?
What I've found so far:
It is possible to read it from headers:
module.exports = function (context, req) {
var ip = req.headers['x-forwarded-for']
}
Is it reliable to get the ip this way, since it can be easily changed on the way to the function?
Yes it is reliable, because Azure web server will overwrite x-forwarded-for as it knows it is forwarding from load balancer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With