Search code examples
jsonfirebasefirebase-hosting

How to create a maintenance page with a 503 code in Firebase?


Using the following firebase.json, I'm able to redirect users to my desired maintenance.html page. However, the page is retrieved with a 304 status code. I would like it to be retrieved with a 503 status code to indicate to a search engine that this is temporary maintenance. I've attempted to set the header manually but it doesn't appear to work. How can this be accomplished in 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"
        } ]
      }
    ]
  }
}

Solution

  • Here's what ended up working for me:

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