Firebase Hosting mime type

时光毁灭记忆、已成空白 提交于 2019-12-22 07:35:11

问题


Has anyone found a way to set the mime type returned in the Content-Type header when hosting a file using Firebase Hosting? The docs say they support some headers in their rules file but not the content-type and I tied it anyway but fails the 'firebase deploy' due to error 'hosting.headers[0].headers[0].key is not one of enum values'. Also, the file i need to serve cannot have an extension which makes things harder for firebase to auto discover the type of the file.


回答1:


I tested this and it seems to work. Also for your second issue why not set an extension anyways but change it to the mimetype you need?

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",    
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "headers": [
      {
        "source": "**/*.@(datagz|memgz|mem|data)",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/octet-stream"
          }
        ]
      } 
    ]
  }
}


来源:https://stackoverflow.com/questions/37727745/firebase-hosting-mime-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!