简体   繁体   中英

Firebase hosting showing welcome page after deploying angular 6 app?

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??

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.

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

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 .

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"
      }
    ]
  }
}

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

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

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.

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

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",
   ...
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM