繁体   English   中英

在 Callable Firebase 函数中获取请求的 URL

[英]Get the requesting URL in Callable Firebase Functions

我有一项服务将 html 共享给多个客户端 web 站点。 我需要知道请求来自哪里的 URL。

客户将向他们的网站添加一个自定义脚本,该脚本将加载 Firebase SDK 并调用我的可调用 firebase 函数之一。

exports.testFunction = functions.https.onCall(async (data, context) => {
    //How do you access the requesting URL?
    console.log(context.rawRequest.originalUrl) "/"
    console.log(context.rawRequest.url) "/"
})

谢谢,

HTTP 对可调用函数的请求并不是真正“来自”URL。 他们来自互联网上的任何地方。 它可能是 web 站点、Android 或 iOS 应用程序,或者只是知道调用 ZC1C425Z5274E68A94F1 协议的人

If you're building a web app and you want to pass along the URL of the page making the request, you'll have to add that data into the object that the client passes to the function, which shows up in data .

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM