Search code examples
reactjstypescriptfirebasefirebase-hosting

Firebase default hosting domains: only .firebaseapp.com works but .web.app fails


I'm building a very simple one-page react application using typescript. I tried hosting it using Firebase Hosting. Surprisingly, only the domain [name].firebaseapp.com works but [name].web.app shows the "Site not found" default page:

site-not-found image

I am using a basic firebase config (the default one you get using firebase init):

{
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

I get the "Site not found" when I go on [name].web.app. I would have suspected something was wrong with the index.html, the rewrites, the build folder, etc... but then why would I see the page functional on [name].firebaseapp.com and hosted nicely and it should be?

There is a few things I suspect:

  • The domain name is not available from firebase itself (although why would firebase name the domain something that is invalid if that was the case when creating the project)
  • The files are being pushed to the [name].firebaseapp.com domain only (in that case, how can you control that?)

Solution

  • The same weird problem happened to me this weekend. Exact symptoms:

    • before any deployments, I opened example.web.app but not example.firebaseapp.com
    • after the first deployment, example.web.app shows "Site not found" but example.firebaseapp.com works as expected. Consequently my customer domain shows "Site not found" as well.

    Per one of the suggestions by support, now fixed by these commands:

    curl -X PURGE https://your.notworking.url
    

    For my case, it was just example.web.app and my custom domain. So fixed in 20 seconds.


    Suggestions that did NOT work:

    • messing with the browser (clear browser cache, incognito mode etc)
    • re-deploying

    Explanation:

    The site not found thing got cached on their CDN server. So naturally, clearing local browser cache did not work. Weirdly re-deploying also did not working.

    Another helpful note is, in the response there is a x-served-by header, which tells you the CDN server your web app is cached on.

    Special thanks to Hugo Varela from firebase support.