我试图为我的域和其他子域实现跨域身份验证。目前,我的后端正在通过防火墙云功能运行。因此,我的后端域类似于https://my-region-firebase-project-id.cloudfunctions.net。
我在添加这样的曲奇:
res.cookie("foo", "bar", {
domain: "mydomain.com",
path: "/",
httpOnly: false,
maxAge: 1209600000,
sameSite: "None",
secure: true
});这不是把饼干放在我的前端。表示通过set-cookie头设置cookie的尝试被阻止,因为它的域属性对于当前主机url无效。
我甚至试着在域名前面加上一个点,比如:.mydomain.com。但还是同样的错误。
我不能将自定义域添加到我的firebase云函数中,因为firebase不支持其他区域的自定义域,只支持us-central1 1。
我漏掉了什么吗?或者有什么解决办法吗?
NB:我可以从云函数中设置cookies,问题是函数域和我的前端域完全不同。
发布于 2022-01-23 04:47:31
您可以将Firebase托管路径映射到云函数!
您的Firebase宿主站点可以连接自定义域。例: example.com.完成后,您可以更新firebase.json中的宿主配置,以添加自定义重写/重定向。
"hosting": {
// ...
// Directs all requests from the page `/bigben` to execute the `bigben` function
"rewrites": [ {
"source": "/bigben",
"function": "bigben"
} ]
}创建对Firebase函数之一的自定义重写。例如:example.com/authenticate -> myAuthenticationFunction.
请参阅这里的详细信息:https://firebase.google.com/docs/hosting/full-config#rewrite-functions
https://stackoverflow.com/questions/69384994
复制相似问题