Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

409
Views
Firebase Functions : How to get IP address from client?

I'm trying to get the IP address from the client in the firebase function by using javascript . Why do I need IP? To make whitelist IPs that can access my functions.

my goal: access my function by IP address

I tried to use this method but didn't work for me it give me 'undefined' :

exports.getIP = functions.https.onRequest(async (req, res) => {
var call = req.ip
console.log(call);
res.send(call);
});

exports.getIP = functions.https.onRequest(async (req, res) => {
  var call = req.headers['x-forwarded-for']
  console.log(call);
  res.send(call);
  });

Here when I call req.headers :

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Both the 'x-forwarded-for' and x-appengine-user-ip headers will be added when you deploy your Cloud functions. It seems you are using Firebase Functions emulator which runs on localhost (since the host header is localhost:5001). You can try deploying the function and logging the IP.

The X-Forwarded-For (XFF) header is a de-facto standard header for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or a load balancer.

The X-Appengine-User-IP is set by App Engine.

When you emulate functions locally there is no proxy in between hence those headers are missing.

References:

  • MDN - X-Forwarded-For

  • App Engine Headers

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!