![](/img/trans.png)
[英]A way to get the IP address of a user in Firebase Authentication?
[英]Get users IP address from Firebase Callable function
如何從onCall
Firebase 函數訪問用戶 IP 地址...
exports.MyFunction = functions.https.onCall((data, context) => {
var IPAddress; //???
console.log(IPAddress)
});
我看到我可能能夠通過context.rawRequest.connection.remoteAddress
獲取 IP 地址,但后來我看到了關於http
函數的這篇文章,我不確定如何將onCall
函數的標頭設置為fastly-client-ip
。
有什么建議?
看:
https://firebase.google.com/docs/reference/functions/providers_https_.html#oncall https://firebase.google.com/docs/reference/functions/providers_https_.callablecontext.html https://firebase.google。 com/docs/reference/functions/providers_https_.request.html#ip
exports.myCallable = functions.https.onCall((data, context) => {
return context.rawRequest.ip;
});
如果您需要路線信息:
https://firebase.google.com/docs/reference/functions/providers_https_.request.html#ips
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.