【问题标题】:firebase provided hosting-url which is not displaying my angular project's index pagefirebase 提供了未显示我的 Angular 项目的索引页面的托管 URL
【发布时间】:2018-11-03 02:49:48
【问题描述】:

用于进行 Firebase 托管:-

  1. 使用“ng build --prod”在 Angular 项目中创建了 dist 文件夹。

  2. firebase login

3.

  • 在 console.firebase.google.com 中创建项目
  • firebase 初始化
  • 选择 firebase CLI 功能作为托管。
  • 我之前创建的相同项目名称在这里选择相同。
  • 输入公共目录作为 dist。
  • 说是的水疗中心。
  • 拒绝覆盖 index.html

然后

  1. firebase deploy

    它为我提供了网址:- https://projectname.firebaseapp.com/

  2. firebase open

但是当我打开托管网址时,“欢迎页面确认 --Firebase 托管设置完成”正在显示。

"image of Page displaying"

请建议我在哪里做错了?以及我的项目的索引页将如何开始显示。

注意:- 我没有使用 firebase 数据库,所以我在初始化时只选择托管。

【问题讨论】:

    标签: angular firebase hosting firebase-hosting


    【解决方案1】:

    也许您应该更改public 属性并添加您的应用名称。

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

    【讨论】:

    • 似乎 firebase 不会尝试遍历 dist 中的目录来罚款候选人服务。您必须明确指定它
    【解决方案2】:

    当您运行 firebase init 时,它会询问您公共 HTML 内容存储在哪个子文件夹中。其默认值为public。如果您没有明确键入不同的值,那么您的 index.html 将需要位于该位置。

    或者,在文本编辑器中打开 firebase.json 并将 public 属性的值更改为指向您正在使用的文件夹。所以像:

    {
      "hosting": {
        "public": "dist"
      }
    }
    

    另见documentation on Firebase Hosting configuration

    【讨论】:

    • 在使用 Angular CLI 的 Angular 6+ 应用程序中,这将是 "dist/app-name"
    猜你喜欢
    • 2017-10-25
    • 1970-01-01
    • 2021-09-21
    • 2010-12-05
    • 2018-09-17
    • 1970-01-01
    • 2021-01-29
    • 2020-04-12
    • 2016-08-04
    相关资源
    最近更新 更多