本文介绍了如何在 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 地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!