【发布时间】:2020-04-29 21:53:28
【问题描述】:
我有一项服务可以将 html 共享给多个客户端网站。我需要知道请求来自的 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) "/"
})
谢谢,
【问题讨论】:
-
您必须通过发出请求的页面将 URL 传递到云函数中。使用
window.location.href获取页面URL并加载到data
标签: node.js firebase express google-cloud-functions