angularfirebasefirebase-hostingfirebase-tools

Deploy angular app to firebase hosting 404 error


After "firebase deploy" command, I have a 404 error...

I'm trying to deploy an angular app on firebase hosting but I have a 404 error (don't find index.html).

firebase login : is OK firebase projects:list : return a table with my project AAA

ng build --configuration production : create dist/abc/browser/ (I don't understand why my source was build in browser repertory...)

firebase init hosting : create this firebase.json firebase.json :

{ "hosting": { "public": "dist/abc", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } }

firebase deploy : finish with OK but when I'm trying to open the link, I have a 404

I think, the issue is the browser repertory but I'm trying tu change firebase.json with "public": "dist/abc/browser",

And it doesn't work...

Do you have an idea ?

Thanks a lot.


Solution

  • Run the command ng build to generate the build files. Then, navigate to the build folder and locate the index.html file. Copy the path to this file, which in your case is build/abc/browser/index.html (note that the path might vary depending on your project's configuration).

    Next, update your Firebase hosting configuration by adding the following code:

    {
      "hosting": {
        "public": "build/abc/browser", // update you path here
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "rewrites": [
          {
            "source": "**",
            "destination": "/index.html"
          }
        ]
      }
    }