[英]Get users IP address from Firebase Callable function
How can I access the users IP address from an onCall
Firebase function...如何从onCall
Firebase 函数访问用户 IP 地址...
exports.MyFunction = functions.https.onCall((data, context) => {
var IPAddress; //???
console.log(IPAddress)
});
I saw that I might be able to get the IP address with context.rawRequest.connection.remoteAddress
but then I saw this post regarding an http
function, and I'm not sure how to set the headers on an onCall
function to fastly-client-ip
.我看到我可能能够通过context.rawRequest.connection.remoteAddress
获取 IP 地址,但后来我看到了关于http
函数的这篇文章,我不确定如何将onCall
函数的标头设置为fastly-client-ip
。
Any suggestions?有什么建议?
See:看:
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 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;
});
If you need route info:如果您需要路线信息:
https://firebase.google.com/docs/reference/functions/providers_https_.request.html#ips https://firebase.google.com/docs/reference/functions/providers_https_.request.html#ips
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.