Search code examples
firebasecreate-react-appfirebase-hostingfirebase-cli

Deploying a Firebase app breaks before refresh


Whenever I deploy my Firebase app for hosting that is a packaged Create-React-App then the first time the browser loads it the console shows:

main.27e9b1c2.js:1 Uncaught SyntaxError: Unexpected token <

F5 refresh fixes it. Then the site is working perfectly until the next time I deploy.

I am using firebase hosting and firebase tools to deploy. The number on the mainjs is the current build.


Solution

  • you can disable cache in firebase.json

    "headers": [
        {
          "source": "/service-worker.js",
          "headers": [{ "key": "Cache-Control", "value": "no-cache" }]
        }
      }