Firebase Hosting MIME类型 [英] Firebase Hosting mime type
问题描述
在使用Firebase托管托管文件时,是否有人找到一种设置Content-Type标头中返回的mime类型的方法?文档说他们在规则文件中支持某些标头,但不支持内容类型,我仍然将其绑定,但由于错误"hosting.headers [0] .headers [0] .key"不是其中之一,因此无法进行"firebase部署"枚举值".另外,我需要提供的文件不能具有扩展名,这会使Firebase很难自动发现文件类型.
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.
推荐答案
我对此进行了测试,它似乎可以工作.另外,对于第二个问题,为什么不设置扩展名,而是将其更改为所需的mimetype?
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"
}
]
}
]
}
}
这篇关于Firebase Hosting MIME类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!