0

Am trying to get the IP address of the client in my firebase cloud function, so when I run my code with the firebase emulator, i got undefined in the console. When I tried the same code without firebase cloud functions using the app.listen() being able to get an IP address from the request.

const app = express()   
app.use(cors())   
app.use(express.json())

app.get('/clientIp', (req, res) => { 
  console.log(req.socket.remoteAddress || req.headers["x-forwarded-for"])  
  res.end()
})

exports.getIp = functions.https.onRequest(app)
Dharmaraj
  • 29,469
  • 5
  • 26
  • 55

0 Answers0