Firebase hosting deployment error Error: Error: 404, Requested entity was not found

Firebase hosting deployment error Error: Error: 404, Requested entity was not found

我在 firebase 上托管了一个静态网站,我正在使用 node.js。 当我尝试部署我的网站时,我遇到了这个错误。

 C:\Users\Ankur-PC\Desktop>firebase deploy

=== Deploying to 'wo*****win'...

i  deploying hosting

**Error: HTTP Error: 404, Requested entity was not found.**

我也在尝试使用这些命令来解决这个错误

npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools

除非你的网站源在C:\Users\Ankur-PC\Desktop,否则你在错误的目录下执行命令

尝试 cd [source dir] 然后部署

遇到同样的问题,终于解决了。

1.登录 2. firebase use --add(选择正确的Project ID) 3. firebase init(select 托管,比正确的项目 ID) 4. 如果需要(npm 运行 构建) 5. 火力部署

解决方案是 2 选择正确的项目 ID 因为某些 firebase 命令如何自动引用错误的项目 ID

祝你好运

我不得不将 site 属性 添加到 firebase.json 来解决这个问题。

{
  "hosting": {
    "site": "my-app-id",
    "public": "app",
    ...
    ...
}

如果您重定向到 Cloud 运行 或 Cloud Functions,请确保它是 运行。

当我在 CLI 中启动项目,然后在同一个项目中设置第二个主机时发生了这种情况。

解决方案是编辑 firebase.json 并添加您要部署的新主机:

{
  "hosting": [
    {
      "target": "web-page", // <-- This is a nickname of a resource (a hosting in firebase)
      "public": "public",
      ....
    },
    {
      "target": "web-app",
      "public": "public",
      ....
    },

  ]
}

现在你必须select目标:

firebase target:apply hosting [name] [resource]

例如,假设名称是 .json 中的“web-page”,而您定位的主机名称是“hosting-web”,最后一个就是名称您在 Firebase 控制台中使用:

firebase target:apply hosting web-page hosting-web

更多参考: https://firebase.google.com/docs/cli/targets

将您的 Firebase npm 包更新到最新版本。对我有用

npm install -g firebase-tools

您必须确保在 Firebase 控制台中添加了 Web 应用程序。

然后,转到“构建”->“托管”并进行设置。系统将提示您为站点添加名称。复制您在此处框中键入的内容...

...并将其添加到您的 firebase.json 文件中:

"hosting": {
"site": "stack-overflow-example", // here
"public": "build/web",
"rewrites": [
  {
    "source": "**",
    "destination": "/index.html"
  }
]
}

我在尝试拥有主域和子域时遇到了同样的问题。

问题是这条消息 404, Requested entity was not found 因为我试图将我的子域部署到托管服务器并且 resource_id 实体在 .firebasesrc 的文件中不存在 我在 targets 文件中添加了与 firebase 托管项目 ID 相同的 ID问题已经解决。

我尝试了以上所有解决方案,但都没有用。 我就是这样解决的。

  1. 删除 firebase 文件和 dist 文件夹 {firebaserc, firebase.jason, dist}

  2. 现在重新构建并执行所有步骤