如何在Firebase中使用503代码创建维护页面?

时间:2018-07-08 15:23:44

标签: firebase firebase-hosting

使用以下firebase.json,我可以将用户重定向到所需的maintenance.html页面。但是,该页面使用304状态代码检索。我希望使用503状态代码来检索它,以指示搜索引擎这是临时维护。我试图手动设置标题,但似乎无法正常工作。如何在Firebase中完成?

{
  "hosting": {
    "public": "build",
    "ignore": [],
    "redirects": [ {
      "source": "/index.html",
      "destination": "/maintenance.html",
      "type": 307
    } ],
    "rewrites": [
      {
        "source": "**"
        , "destination": "/index.html"
      }
    ],
    "headers": [
      {
        "source": "/maintenance.html",
        "headers": [ {
          "key": "status",
          "value": "503"
        } ]
      }
    ]
  }
}

1 个答案:

答案 0 :(得分:0)

以下是对我有用的东西:

{
  "hosting": {
    "public": "build",
    "ignore": [],
    "redirects": [
      {
        "source": "/index.html",
        "destination": "/maintenance.html",
        "type": 307
      }
    ],
    "headers": [
      {
        "source": "/maintenance.html",
        "headers": [ {
          "key": "status",
          "value": "503"
        } ]
      }
    ]
  }
}