Search code examples
jsonfirebasefirebase-hosting

"Incorrectly formatted 'headers' entry" when setting Last-Modified header


I'm trying to set the Last-Modified header for my resources so they can be properly cached. However, when I run firebase deploy I get the following error:

FIREBASE WARNING: set at /hosting/headers/dstaley failed: permission_denied
Settings Error - Incorrectly formatted "headers" entry in the firebase.json

My firebase.json is as follows:

{
  "firebase": "dstaley",
  "public": "dist",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ],
  "rewrites": [
    {
      "source": "**",
      "destination": "/index.html"
    }
  ],
  "headers": [
    {
      "source": "**/*.@(js|css)",
      "headers": [
        {
          "key": "Cache-Control",
          "value": "max-age=31536000"
        }
      ]
    },
    {
      "source": "**/*.@(js|css|html)",
      "headers": [
        {
          "key": "Last-Modified",
          "value": "Thu, 28 Aug 2014 16:25:05 GMT"
        }
      ]
    }
  ]
}

The file looks properly formatted, and the permission_denied error leads me to believe that it's not possible to set the Last-Modified header with Firebase hosting. Any ideas?


Solution

  • As explained in the documentation:

    We currently only support the Cache-Control and the Access-Control-Allow-Origin headers as a key.

    So no, you can't (currently) do that.