You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否通过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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 01:55:17