Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get client IP address in a Firebase cloud function?

When saving data to Firebase database with a Firebase cloud function, I'd like to also write the IP address where the request comes from.

However, req.connection.remoteAddress always returns ::ffff:0.0.0.0. Is there a way to get the actual IP address of the client that makes the request?

like image 645
tuomassalo Avatar asked Dec 30 '17 10:12

tuomassalo


1 Answers

The clients IP is in request.ip.

Example:

export const pay = functions.https.onRequest((request, response) => {   console.log(`My IP is ${request.ip}`); }); 
like image 71
Luke Avatar answered Oct 01 '22 18:10

Luke