Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

417
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda