Firebase hosting showing welcome page after deploying angular 6 app?
Asked Answered
P

12

14

I want to develop the angular 6 apps, but after deploying firebase showing only welcome page.

Here are the steps I have taken to deploy.

  1. installed firebase-tools
  2. ng build --prod (in my app)
  3. firebase init
  4. Are you ready to proceed? (Y/n) y
  5. (*) Hosting: Configure and deploy Firebase Hosting sites
  6. What do you want to use as your public directory? (public) dist
  7. Configure as a single-page app (rewrite all urls to /index.html)? (y/N) y
  8. File dist/index.html already exists. Overwrite? (y/N) y
  9. Firebase initialization complete!
  10. In this step, I have deleted dist folder and run ng build --prod again
  11. angular build app in a subfolder inside dist directory hence I copied all the content from the subdirectory which contains index.html to dist/.
  12. firebase deploy
  13. firebase open hosting:site

but after doing all that I am still getting welcome page in the link.

What am I doing wrong!?

Phraseology answered 4/6, 2019 at 15:31 Comment(0)
M
23

Try: 8. File dist/index.html already exists. Overwrite? (y/N) N and open link to your app in incognito mode. Seriously, I stuck for hours because this firebase index got cached in my case, so this was the reason why I could't see my app after deploy.

Moores answered 5/6, 2019 at 21:20 Comment(3)
Why does it work on incognito mode??Carbamate
You can also just hold shift and click refresh which will remove the cache for that pageCourses
@Carbamate Because the issue is that the defualt "Firebase Hosting Complete" page is cached in the browser (in other words stored locally) so instead of actually looking at the contents of the new index.html file, it's just using the locally stored one. Incognito mode doesn't use cached pagesCourses
W
5

The Problem is: firebase is looking for the index.html file, sometimes it is not present directly in the dist directory

Solution: update the public path in the firebase.json to "public":"dist/ProjectName" or path to the index.html file in the dist folder

Example

{
  "hosting": {
    "public": "dist/<YourProjectName>",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/dist/index.html"
      }
    ]
  }
}
Wagonette answered 29/9, 2021 at 7:10 Comment(1)
For me, I had to change the "public" value to "build/web", but that worked! Maybe because I am using Flutter to build my app?Katinakatine
P
2

Browser cache was my issue as well. As mentioned above, try in incognito or use proxysite.com (very useful website) to avoid browser cache

Physiology answered 24/10, 2020 at 7:28 Comment(0)
U
1

In my case, I was initializing firebase inside the project directory (src). Just check the directory you are in. It should be on the top level.

After you build it and try to deploy it, it will be the same since the web page has been cached. So to make sure use in incognito.

Ulrica answered 2/7, 2021 at 19:47 Comment(0)
W
1

In my case I had to change public to dist in firebase.json so it pointed to my dist folder (rather than the public folder which contains the holding page) after I added Firebase Functions to my project:

"hosting": {
   "public": "dist",
   ...
}

Whitebeam answered 23/11, 2022 at 12:0 Comment(0)
D
0

Check the path on terminal .if the problem still exists then delete firebase auto created folders and deploy the project

Dykes answered 3/5, 2021 at 10:6 Comment(0)
D
0

Configure as a single-page app (rewrite all urls to /index.html)? No ? Set up automatic builds and deploys with GitHub? No

  • Wrote public/404.html ? File public/index.html already exists. Overwrite? No

This error is generated by index.html inside public folder of your website folder.

Dagnah answered 25/7, 2021 at 4:40 Comment(0)
H
0

The welcome page is an automatically generated index.html file found in public folder. I replaced that file with my own index.html file, then use firebase deploy --only hosting commands to update the changes.

Hydranth answered 20/12, 2022 at 9:31 Comment(0)
S
0

first you should login firebase login after that write command firesbe init

first steps

  1. What do you want to use as your public directory? (public) dist/projectname
  2. File dist/index.html already exists. Overwrite? (y/N) N

after completing the process you should run (npm run build) command and it generates the build file. after that you should got to firebase.json and put build folder in public directory

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

and the last not the least firebase deploy. works perfectly

Spoilage answered 10/3, 2023 at 3:31 Comment(0)
C
0

After trying to install things again, in my case, in firebase.json, I changed the value of public to build/web because I found index.html located in project/build/web folder.

Thank you all!

Cradle answered 12/3, 2024 at 2:13 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Gabriel
P
-1

This worked for me:

  • Delete .firebase folder
  • Delete .firebaserc
  • Delete firebase.json

Now run as follow:

$ firebase init hosting
? File build/web/index.html already exists. Overwrite? No
$ firebase deploy --only hosting
Purebred answered 15/1, 2021 at 15:36 Comment(0)
P
-1

firebase init hosting ? File build/index.html already exists. Overwrite? No npm run build firebase deploy --only hosting

Pterosaur answered 1/7, 2022 at 21:24 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Sharisharia

© 2022 - 2025 — McMap. All rights reserved.