Firebase 将多个子域托管到具有 1 个项目的应用目录

Col*_*gic 9 subdomain dns firebase firebase-hosting

我目前有一个应用程序部署到 Firebase 托管,其结构如下:

public/
    appSub1/
        index.html
    appSub2
        index.html
    index.html
Run Code Online (Sandbox Code Playgroud)

我已经添加并连接了我的子域,以便

appSub1.mysite.com/ -> app.firebaseapp.com/
appSub2.mysite.com/ -> app.firebaseapp.com/
Run Code Online (Sandbox Code Playgroud)

我正在尝试配置重定向以将子域与正确的应用程序子文件夹正确关联,以便

appSub1.mysite.com/ -> app.firebaseapp.com/appSub1/
appSub2.mysite.com/ -> app.firebaseapp.com/appSub2/
Run Code Online (Sandbox Code Playgroud)

如果我手动添加子路径,应用程序仍然可以正确显示,但没有它们就不行。所以会以appSub1.mysite.com/空白页appSub1.mysite.com/appSub1/结束,但会以正确的方式结束index.html

这是我当前的托管配置 firebase.json

"hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "appSub1.mysite.com/**",
        "destination": "/appSub1/**",
        "type": 301
      },
      {
        "source": "appSub2.mysite.com/**",
        "destination": "/appSub2/**",
        "type": 301
      }
    ]
  },
Run Code Online (Sandbox Code Playgroud)

小智 1

我推荐以下内容:

  1. 在 Firebase 上升级到 Blaze 计划
  2. 使用Firebase多站点托管方法(参考: https: //firebase.google.com/docs/hosting/multisites
  3. public/app1and分解public/app2为两个独立的托管项目目标 - 例如app1and app2- 因此,默认情况下托管地址将为app1.firebaseapp.comand app2.firebaseapp.com(或者从 2019 年 5 月开始,您还将获得一个.web.app域名 -app1.web.app
  4. 通过在域注册表上配置 DNS 条目来连接各个子域(请参阅: https: //medium.com/@fransandi/use-firebase-multisite-hosting-to-associate-multiple-domains-subdomains-to-your-project-ee099109bfe9