【问题标题】:Firebase dynamic links and hosting on the same (custom) domainFirebase 动态链接和托管在同一(自定义)域上
【发布时间】:2021-02-21 17:43:32
【问题描述】:

我正在使用 Firebase 托管来托管网站,并且我正在使用自定义域名。 我希望我的网站成为让我们说的目的地:https://example.com

我还使用使用相同域但使用不同前缀的 firebase 动态链接。

像这样:https://links.example.com

网站主机和动态链接工作正常,但问题是我不知道如何以允许站点 (example.com) 和子域 ( links.firebase.com),我可以将其用于我的动态链接。

如果我使用以下重写,动态链接将起作用:

    "rewrites": [
      {
        "source": "/**",
        "dynamicLinks": true
      }
    ]

但是这样主网站 (example.com) 会显示一条关于不是有效动态链接的消息,而不是显示 index.html

TL/DR 我想知道是否可以让网站 (example.com) 和动态链接 (links.example.com) 在同一个域 (example) 上工作?

提前致谢

编辑 1: 我已重命名 index.html,所以这就是我没有看到该网站的原因。现在我把它改回来了,但是动态链接不行。 links.example.com 显示 index.html

编辑 2: 它最终按预期工作:example.com 和 links.example.com 指向 index.html,而像 links.example.com/aShortDynamicLinkCode 这样的任何格式都会激活动态链接。

我在 Firebase.json 中使用了以下重写来实现这一点

      {
        "source": "**",
        "dynamicLinks": true
      },
      {
        "source": "/**",
        "dynamicLinks": true
      },

【问题讨论】:

    标签: firebase firebase-hosting firebase-dynamic-links custom-domain


    【解决方案1】:

    如果您的public 目录中有index.html,即使您指定了重写,它也会在/ 上提供服务(请参阅文档中的serving priority)。

    如果您没有看到您的index.html,则表明某些内容可能配置错误。仔细检查您的 index.html 是否位于您的 public 目录的根目录中,并且部署的文件数量是否准确。

    【讨论】:

    • 感谢您的快速响应,我已经更改了 index.html 名称,现在我将它改回了网站工作,问题是动态链接不“links.example.com”也显示index.html
    • 是的,这是正确的——同一个站点将始终为与其连接的所有域提供相同的内容。如果这不是目标,您可能需要为动态链接设置 a second site
    猜你喜欢
    • 2020-12-10
    • 2018-09-13
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多