Firebase 托管部署错误错误:错误:404,找不到请求的实体

问题描述 投票:0回答:11

我在 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.**

我也在尝试这些cmd来解决这个错误

npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools
node.js web-deployment firebase-hosting
11个回答
50
投票

我必须将

site
属性添加到
firebase.json
才能解决此问题。

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

5
投票

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

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

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

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

2
投票

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

npm install -g firebase-tools


1
投票

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

尝试 cd [源目录] 然后部署


0
投票

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

1。火力基地登录 2. firebase use --add (选择正确的项目ID) 3. firebase init(选择托管,而不是正确的项目ID) 4.如果需要(npm run build) 5.Firebase部署

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

祝你好运


0
投票

如果您重定向到 Cloud Run 或 Cloud Function,请确保其正在运行。


0
投票

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

  ]
}

现在你必须选择目标:

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


0
投票

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

问题是这条消息

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


0
投票

我尝试了上述所有解决方案,但没有成功。 我就是这样解决的。

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

  2. 现在再次构建并遵循所有步骤


0
投票

Firebase 不接受带有空格的

groups
名称。例如:- iOS

iOS SIT 测试仪总是失败

错误:无法分发给测试人员/组:HTTP 错误:404, 找不到请求的实体。

JinglePayTesters 成功的地方没有任何问题。

    # Deploy on Firebase 
  - task: Bash@3
    displayName: "Upload to firebase app distribution"
    inputs:
      targetType: "inline"
      script: |
          npm i -g firebase-tools
          ls -la $(Build.BinariesDirectory)/output/
          firebase appdistribution:distribute  *.ipa \
            --app "$(app_id)" \
            --token "$(firebasetoken)" \
            --groups "JinglePayTesters" \
            --release-notes "From Azure Devops" \
            --debug \
      workingDirectory: '$(Build.BinariesDirectory)/output/'

0
投票

由于

.firebaserc
文件配置不正确,我收到了相同的错误。我将项目的名称与托管目标的名称混淆了。正确配置的文件看起来像这样:

{
  "projects": {
    "default": "dev-project",
    "dev": "dev-project",
    "prod": "prod-project"
  },
  "targets": {
    "prod-project": {
      "hosting": {
        "app-one": [
          "prod-project-hosting-target-for-app-one"
        ],
        "app-two": [
          "prod-project-hosting-target-for-app-two"
        ]
      }
    },
    "dev-project": {
      "hosting": {
        "app-one": [
          "dev-project-hosting-target-for-app-one"
        ],
        "app-two": [
          "dev-project-hosting-target-for-app-two"
        ]
      }
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.