Search code examples
firebasefirebase-hosting

How to turn off default domain in firebase hosting - firebase


I just set up new Firebase Hosting and my custom domain and my web page, etc...

Everything works great, except what is really bothering me are default Domains:

  • projectname.web.app
  • projectname.firebaseapp.com

Looking around googling, I have not found a solution, how to remove or disable them... Any suggestion? This seems really annoying. It could be a show stopper for me...


Solution

  • I have contacted Firebase Hosting help. According to them, you can not disable, remove, hide or make them private. Meaning they will always be there and be accessible to the public...

    Their official answer;

    • what you can do is to add in the header (suggested by Firebase Hosting):
    <link rel="canonical" href="http://myapp.domain.com/" />
    

    However, this did not work for me out of the box. I asked Google to re-index my web page (still waiting at this point to re-index).

    • another approach (also suggested by Firebase Hosting), redirect:
    //check if the url
    if (window.location.hostname == "yourapp.web.app" || 
        window.location.hostname == "yourapp.firebaseapp.com") {
           window.location.href = 'http://yourcustomdomain'; 
    }