【问题标题】:Firebase Hosting Deployment Error HTTP 400 ErrorFirebase 托管部署错误 HTTP 400 错误
【发布时间】:2018-10-13 15:27:37
【问题描述】:

在解决了一些问题后,我试图在 firebase 上重新部署我的 react 应用程序。但是重新部署会出错。不知道是什么问题。

我也尝试查看其他帖子中提供的答案,但对我没有任何帮助。

firebase.json详情如下:

{
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [{
      "source": "**",
      "destination": "/index.html",
      "headers": [{
        "key": "Cache-Control",
        "value": "max-age=0"
      }]
    }]
  }
}

错误:HTTP 错误:400,hosting.rewrites[0] 不完全是来自 [子模式 0],[子模式 1]

这是我第一次遇到这个错误。所以不知道是什么问题。

【问题讨论】:

    标签: firebase firebase-hosting


    【解决方案1】:

    标题选项在rewrites 参数内查找。相反,您需要搬出:

    "hosting": {
        "public": "build",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "rewrites": [{
          "source": "**",
          "destination": "/index.html"
        }],
        "headers": [{
            "key": "Cache-Control",
            "value": "max-age=0"
        }]
      }
    

    【讨论】:

      【解决方案2】:

      好的,问题出在标题上。删除它解决了这个问题。我将它保留在那里,以便在用户更新网站后重新加载网站。它以前工作正常。不知道是什么问题。如果其他人可以解决此问题或告诉我我做错了什么,请保持开放状态。 :)

      【讨论】:

        【解决方案3】:

        您缺少标题的 source 选项,看看我是如何构建我的:

        {
          "hosting": {
            "public": "build",
            "headers": [
              {
                "source": "/service-worker.js",
                "headers": [
                  {
                    "key": "Cache-Control",
                    "value": "no-cache"
                  }
                ]
              }
            ]
          }
        }
        

        关于如何构造标题的文档是here

        【讨论】:

          【解决方案4】:
          "hosting": {
          "public": "build",
          "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
          ],
          "rewrites": [{
            "source": "**",
            "destination": "/index.html"
          }],
          "headers": [{
              "key": "Cache-Control",
              "value": "max-age=0"
          }]
          

          }

          【讨论】:

            猜你喜欢
            • 2019-04-02
            • 2018-07-11
            • 2020-04-20
            • 1970-01-01
            • 2021-01-28
            • 1970-01-01
            • 2019-11-21
            • 2019-07-11
            • 2018-07-10
            相关资源
            最近更新 更多