Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get users IP address from Firebase Callable function

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?

like image 395
nachshon f Avatar asked Jul 04 '19 19:07

nachshon f


People also ask

Does firebase capture IP address?

Retention: Firebase Authentication keeps logged IP addresses for a few weeks. It retains other authentication information until the Firebase customer initiates deletion of the associated user, after which data is removed from live and backup systems within 180 days.

Does firebase have Webhooks?

Firebase Webhooks automates the workflow for companies and Developers by triggering the defined events via URL. Firebase Webhooks Integration is the simplest and most efficient way to communicate between app and Firebase.

Does firebase use HTTP requests?

You can connect an HTTP function to Firebase Hosting. Requests on your Firebase Hosting site can be proxied to specific HTTP functions. This also allows you to use your own custom domain with an HTTP function.


1 Answers

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

like image 196
Chase B. Gale Avatar answered Oct 09 '22 01:10

Chase B. Gale