Firebase 自定义域名
Firebase Custom Domain Name
我在配置自定义域时遇到了很多问题。目前,如果您访问我的站点 www.mydomain.com,它会重定向到默认站点 somecrazyname.firebase.com。在我的 google 域中,我只是将 www.mydomain.com 和 mydomain.com 都重定向到 mycrazyname.firebase.com 只是为了在我弄清楚之前让一些东西活着。我的问题是,当您转到 www.mydomain.com 时,我该如何做到这一点,它会保持在 www.mydomain.com,同时显示我的精彩内容,而不是 somecrazyname.firebase.com。
就我的自定义 url 而言(验证等),一切都已使用 firebase 正确配置。但是,url firebase 给我的是 https mydomain.com(如果你去那里,它会说该站点无法显示),而我在 Google 域上的域是 http。我尝试在我的 firebase json 中配置重定向以及在 Google 域中配置我的综合记录,但没有这样的运气并且我没有想法。我还查看了 firebase 托管自定义域文档,但我只是不明白。
这里有一些视觉效果....
我在 Google 域中看到的重定向
我确定这只是将东西放在正确位置的问题,但我已经尝试了几个小时,但一直没有成功。
您不应为您的域使用重定向(301 或 302)记录。相反,您应该设置 CNAME 记录。修复方法如下:
- 删除屏幕截图中的第二个重定向(重定向到 Firebase 的那个)。
转到 Google 域控制面板的 DNS 选项卡,向下滚动到 自定义资源记录 部分,并添加如下所示的记录:
www | CNAME | _____ | portfolio-6f15b.firebaseapp.com
是合成记录导致了我的问题。我使用的是 CName 记录,在 firebase 支持团队的指导下,它只适用于子域重定向。以下是来自 Firebase 支持团队的电子邮件的一部分。这是她对此的回答以及一些有用的解释。
Firebase uses TXT records for the verification of your custom domain.
On the other hand, CNAME and/or A records are used for redirection. Please take note of the following:
- If you have a subdomain, CNAME records are recommended
Note that the host name with "*" indicates a wildcard. Any subdomains typed before your custom domain will redirect you to your
hosted custom domain.
Otherwise, if you have a custom domain without a subdomain, A records are recommended.
- Note that adding both A records will increase redirection performance
- Also, kindly remove other A records that are not from Firebase to prevent redirection issues
That's about it. Firebase Static Hosting only needs three records
(TXT, CNAME, A). Other than that, you wouldn't have the need to
implement domain forwarding such as your Synthetic records. Moving
forward though, I would suggest you to remove your Synthetic records
and add the A records I have provided on my previous email.
我在配置自定义域时遇到了很多问题。目前,如果您访问我的站点 www.mydomain.com,它会重定向到默认站点 somecrazyname.firebase.com。在我的 google 域中,我只是将 www.mydomain.com 和 mydomain.com 都重定向到 mycrazyname.firebase.com 只是为了在我弄清楚之前让一些东西活着。我的问题是,当您转到 www.mydomain.com 时,我该如何做到这一点,它会保持在 www.mydomain.com,同时显示我的精彩内容,而不是 somecrazyname.firebase.com。
就我的自定义 url 而言(验证等),一切都已使用 firebase 正确配置。但是,url firebase 给我的是 https mydomain.com(如果你去那里,它会说该站点无法显示),而我在 Google 域上的域是 http。我尝试在我的 firebase json 中配置重定向以及在 Google 域中配置我的综合记录,但没有这样的运气并且我没有想法。我还查看了 firebase 托管自定义域文档,但我只是不明白。
这里有一些视觉效果....
我在 Google 域中看到的重定向
我确定这只是将东西放在正确位置的问题,但我已经尝试了几个小时,但一直没有成功。
您不应为您的域使用重定向(301 或 302)记录。相反,您应该设置 CNAME 记录。修复方法如下:
- 删除屏幕截图中的第二个重定向(重定向到 Firebase 的那个)。
转到 Google 域控制面板的 DNS 选项卡,向下滚动到 自定义资源记录 部分,并添加如下所示的记录:
www | CNAME | _____ | portfolio-6f15b.firebaseapp.com
是合成记录导致了我的问题。我使用的是 CName 记录,在 firebase 支持团队的指导下,它只适用于子域重定向。以下是来自 Firebase 支持团队的电子邮件的一部分。这是她对此的回答以及一些有用的解释。
Firebase uses TXT records for the verification of your custom domain.
On the other hand, CNAME and/or A records are used for redirection. Please take note of the following:
- If you have a subdomain, CNAME records are recommended
Note that the host name with "*" indicates a wildcard. Any subdomains typed before your custom domain will redirect you to your hosted custom domain.
Otherwise, if you have a custom domain without a subdomain, A records are recommended.
- Note that adding both A records will increase redirection performance
- Also, kindly remove other A records that are not from Firebase to prevent redirection issues
That's about it. Firebase Static Hosting only needs three records (TXT, CNAME, A). Other than that, you wouldn't have the need to implement domain forwarding such as your Synthetic records. Moving forward though, I would suggest you to remove your Synthetic records and add the A records I have provided on my previous email.