能否通过Firebase将请求转发至其他项目中的Cloud Run容器?
跨项目Firebase Hosting转发请求至Cloud Run的问题
官方同项目配置方案
Firebase官方支持通过代理将请求转发到Cloud Run,同项目下的标准配置是使用serviceId指定目标Cloud Run服务:
"hosting": { // ... // 将所有 `/helloworld` 路径的请求转发至同名Cloud Run容器 "rewrites": [ { "source": "/helloworld", "run": { "serviceId": "helloworld", // 部署容器时设置的服务名称 "region": "us-central1" // 可选参数,默认值为us-central1 } } ] }
跨项目场景的尝试与问题
当Cloud Run与Firebase Hosting属于同一账号下的不同项目时,上述serviceId的配置方式无法直接生效。我尝试改用destination字段配置重写规则:
"rewrites": [ { "source": "/api/**", "destination": "MY-CLOUD-RUN-APP-URL>/api/**" }, { "source": "**", "destination": "/index.html" } ]
但该配置并未解决跨项目转发的问题。
内容的提问来源于stack exchange,提问作者Ege
相关产品推荐
相关产品推荐

