Reputation: 3680
How can I access the users IP address from an onCall
Firebase function...
exports.MyFunction = functions.https.onCall((data, context) => {
var IPAddress; //???
console.log(IPAddress)
});
I saw that I might be able to get the IP address with context.rawRequest.connection.remoteAddress
but then I saw this post regarding an http
function, and I'm not sure how to set the headers on an onCall
function to fastly-client-ip
.
Any suggestions?
Upvotes: 7
Views: 3119
Reputation: 386
See:
https://firebase.google.com/docs/reference/functions/providers_https_.html#oncall https://firebase.google.com/docs/reference/functions/providers_https_.callablecontext.html https://firebase.google.com/docs/reference/functions/providers_https_.request.html#ip
exports.myCallable = functions.https.onCall((data, context) => {
return context.rawRequest.ip;
});
If you need route info:
https://firebase.google.com/docs/reference/functions/providers_https_.request.html#ips
Upvotes: 15