Firebase重写函数不拦截根url请求



我在firebase.json中有以下firebase主机配置

{
"target": "app",
"public": "dist/browser",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [{
"source": "/app3/**",
"destination": "/app3/index.html"
},
{
"source": "/app2/**",
"function": "serveApp2"
},
{
"source": "**",
"function": "serveApp1"
}
]
}

这些fireabse函数实际上是为Angular通用应用服务的

当我访问域[https://example.com/或https://example.com/app2]的功能不运行,因为我可以看到功能日志。

但是当我访问应用程序的内部路径[例如https://example.com/some-path或https://example.com/app2/some-path]时,我会得到日志,并且SSR工作正常

为什么firebase hosting不拦截根url请求?请帮忙🙏🙏🙏

您还必须添加专门捕获根节点的字段—这是因为"/**"不通配符"",而是"/"

您可以通过将"/app2**"重定向到serveApp2

来解决这个问题