问题描述
我有两个连接到相同Firebase/Firestore实例的Angular应用程序:
I have two Angular applications that are connecting to the same Firebase/Firestore instance:
我已经使用Express实现了Firebase Cloud Functions,但希望根据发出请求的应用程序有条件地操纵返回的数据.我尝试使用 req.get('origin')
来检测请求的来源,但这总是返回Firebase Cloud(cloudfunctions.net/)提供的URL.
I have implemented Firebase Cloud Functions with Express, but would like to conditionally manipulate the data being returned based on which applications is making the request. I have tried using req.get('origin')
to detect the origin of the request, but that always returns the URL provided by the Firebase Cloud (cloudfunctions.net/).
我可以通过其他方式访问此信息吗?
Can I access this information another way?
推荐答案
您正在寻找"Referer" HTTP请求标头字段.
You are looking for the 'Referer' HTTP request header field.
要访问它,您可以执行以下任一操作:
To access it you can do either:
req.get('Referrer')
req.get('Referer')
req.headers.referer
req.headers.referrer
它检查两者都拼写,无需测试通过了什么.
It checks for both spelling, there is no need to test which is being passed.
这篇关于在Firebase Cloud功能中获取请求URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!