如何在Firebase云功能中获取客户端IP地址? [英] How to get client IP address in a Firebase cloud function?
本文介绍了如何在Firebase云功能中获取客户端IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当使用Firebase云功能将数据保存到Firebase数据库时,我还要写请求来自的IP地址.
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.
但是,req.connection.remoteAddress
始终返回::ffff:0.0.0.0
.有没有办法获取发出请求的客户端的实际IP地址?
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?
推荐答案
如果您正在通过Firebase托管寻找客户端ip,则应使用标头fastly-client-ip
,这将是真实的客户端ip.
If you are looking for the client ip thru firebase hosting you should use the header fastly-client-ip
there will be the real client ip.
这篇关于如何在Firebase云功能中获取客户端IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文