简体   繁体   English

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

[英]Get the requesting URL in Callable Firebase Functions

I have a service that shares html to multiple client web sites.我有一项服务将 html 共享给多个客户端 web 站点。 I need to know The URL of where the request is coming from.我需要知道请求来自哪里的 URL。

The client will add a custom script to their website and the script will load Firebase SDK and call one of my callable firebase functions.客户将向他们的网站添加一个自定义脚本,该脚本将加载 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) "/"
})

Thank you,谢谢,

HTTP requests to callable functions don't really come "from" a URL. HTTP 对可调用函数的请求并不是真正“来自”URL。 They come from anywhere on the internet.他们来自互联网上的任何地方。 It could be a web site, Android or iOS app, or someone who simply knows the protocol to call the function.它可能是 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 . 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