Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Custom Domain Name

I’m having a lot of trouble configuring my custom domain. Currently, if you go to my site www.mydomain.com it redirects to the default somecrazyname.firebase.com. In my google domains, I just have both www.mydomain.com and mydomain.com redirecting to the mycrazyname.firebase.com just for the sake of having something live until I can figure this out. My question is, how do I make it so when you go to www.mydomain.com it stays on www.mydomain.com while showing my amazing content and not somecrazyname.firebase.com. Everything is configured correctly with firebase as far as my custom url goes(verification, etc.). However, the url firebase gave me is https mydomain.com (where if you go there it says the site can't be displayed) where my domain on Google domains is http. I've tried to configure redirects within my firebase json as well as my synthetic records in Google domains, but have had no such luck and am out of ideas. I've also looked at the firebase hosting custom domains documentation and am just not getting it. Here are some visuals.... firebase consolefirebase json

My redirects as seen on Google domains google domain redirects

I'm sure it's just a matter of putting things in the right places, but I have been trying this for a few hours and have not had any luck.

like image 677
kyle Avatar asked Mar 12 '23 12:03

kyle


2 Answers

It was the synthetic records that was causing the issue for me. I was using CName records which, by the direction of the firebase support team is good only for subdomain redirects. Below is part of an email from the firebase support team. This is her answer to this as well as some helpful explanations.

  1. Firebase uses TXT records for the verification of your custom domain.

  2. 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.

like image 146
kyle Avatar answered Mar 23 '23 22:03

kyle


You should NOT be using a redirect (301 or 302) record for your domain. Instead, you should set a CNAME record. Here's how to fix it:

  1. Delete the second redirect in your screenshot (the one that redirects to Firebase).
  2. Go to the DNS tab of your Google Domains control panel, scroll down to the Custom resource records section, and add a record that looks like this:

    www | CNAME | _____ | portfolio-6f15b.firebaseapp.com

like image 30
jburns20 Avatar answered Mar 23 '23 23:03

jburns20