【发布时间】:2021-03-29 08:41:43
【问题描述】:
我正在尝试使用域设置 firebase,以便:
- 我的函数在 mydomain.com/api/functionName 上可用
- 我的主机在 mydomain.com 上可用(或者最好是 mydomain.com/client/,但另一个也可以)
我的firebase.json 看起来像这样:
{
"hosting": {
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
},
{
"source": "/api/helloWorld",
"function": "helloWorld"
}
]
}
}
部署它并在浏览器中访问域后,/ 和 /api/helloWorld 路由将始终将我带到我的客户端应用程序,而不是我的函数。
对我来说真正奇怪的是,当在本地运行模拟器时,托管根本不起作用,但localhost:5000/api/helloWorld 按预期工作并调用该函数。
我在这里做错了什么?感觉好像我的firebase.json 根本没有部署。
更新
这是我的函数定义,如果与它有关的话:
exports.helloWorld = functions
.region("europe-west3")
.https.onRequest((_, response) => {
response.send("Hello from Firebase!");
});
【问题讨论】:
标签: firebase google-cloud-functions firebase-hosting firebase-cli