代码之家  ›  专栏  ›  技术社区  ›  Kamil Kamili

Firebase主机部署错误HTTP 400错误

  •  0
  • Kamil Kamili  · 技术社区  · 6 年前

    在修复了一些问题后,我试图在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,宿主。重写[0]不完全是来自 [子模式0],[子模式1]

    这是我第一次遇到这个错误。所以不知道问题出在哪里。

    3 回复  |  直到 6 年前
        1
  •  0
  •   Cappittall    6 年前

    页眉选项在 rewrites 参数。相反,你需要搬出去:

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

    好吧,问题是头球。去掉它就解决了问题。我把它放在那里,这样当用户更新网站后刷新网站时,网站就会重新加载。以前还不错。不知道是什么问题。如果有人能解决这个问题,或者告诉我我做错了什么,你就把这件事公开

        3
  •  0
  •   Rodrigo Mata    6 年前

    你错过了 source 对于标题选项,请看一下我是如何构建我的标题的:

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

    有关如何构造标头的文档如下所示 here

    推荐文章