在Callable Firebase函数中获取请求的URL [英] Get the requesting URL in Callable Firebase Functions

查看:71
本文介绍了在Callable Firebase函数中获取请求的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一项将html共享到多个客户端网站的服务.我需要知道请求来源的网址.

I have a service that shares html to multiple client web sites. I need to know The URL of where the request is coming from.

客户端将向其网站添加自定义脚本,并且该脚本将加载Firebase SDK并调用我的可调用firebase函数之一.

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.

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.他们来自互联网上的任何地方.它可以是网站,Android或iOS应用程序,也可以是仅了解协议调用该函数.

HTTP requests to callable functions don't really come "from" a 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应用程序,并且想传递发出请求的页面的URL,则必须将该数据添加到客户端传递给该函数的对象中,该对象显示在<代码>数据.

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.

这篇关于在Callable Firebase函数中获取请求的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆