我正在使用我的 firebase 托管设置重定向(重写),以便我可以调用从 google cloud run here运行的 api 。
我尝试将重写字符串从"/api/**"
(应该将所有内容捕获到 page.com/api/** 并将其发送到函数)。删除 index.html 并切换到"**"
以捕获所有路径,包括 index.html。到目前为止没有任何效果。
我的托管 firebase.json 是这样设置的,这有什么问题吗?
{
"hosting": {
"public": "dist/public",
"ignore": ["firebase.json", "**.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"run": {
"serviceId": "next-js-base-api",
"region": "us-central1"
}
}
]
}
}
我也尝试过正常重定向到另一个页面,这不起作用,什么决定了 firebase.json 设置何时开始传播和工作?
更新
我尝试运行托管模拟器并进行了修改后的重写"source": "/api/**"
,结果如下。导航到 /api 返回非崩溃(不重定向),并在浏览器中输出cannot GET /api
导航到 api/wkapi(由 api 端点捕获的子目录)unexpected error
在浏览器中返回
Error: Unable to find a matching rewriter for {"source":"/api/**","run":{"serviceId":"next-js-base-api","region":"us-central1"}}
在控制台中。