0

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.

3
  • Could you post your firebase.json here Commented Aug 29, 2024 at 16:49
  • You may be not using the correct path of the build folder in the public value in json. Please correct that. Just check where you are getting the final build output.
    – user19172501
    Commented Aug 29, 2024 at 17:00
  • Are you using Angular i18n? Commented Aug 29, 2024 at 17:02

1 Answer 1

2

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"
      }
    ]
  }
}
2
  • it's working thanks :). It's odd because I think I tried that yesterday. But maybe I have to wait a while because yesterday I just created the project so maybe the syncs are not immediate? Do you know how to have only dist/abc with the "ng build" instead of dist/abc/browser? Maybe it's a good practice to keep the browser directory? Commented Aug 30, 2024 at 7:50
  • It's generally not possible to have only dist/abc without the browser directory when using ng build in a standard Angular project. Angular projects have two build types: Client-Side Rendering (CSR) and Server-Side Rendering (SSR). For CSR, the build output goes to dist/abc/browser, while for SSR, it goes to dist/abc/server.
    – Ravi Gaud
    Commented Aug 30, 2024 at 15:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.