如何将特定文件的内容类型更改为 application/json?
How do I change the content type to application/json for spesific files?
对于 Matrix 家庭服务器(在 Modular.im 上),您需要 2 个文件:
domain.tld/.well-known/matrix/server
domain.tld/.well-known/matrix/client
...它们还需要 application/json
而不是 firebase 默认的 application/octet-stream
。我该如何更改?
目前firebase.json
的解决方案来自this answer。
$ cat firebase.json
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/.well-known/matrix/server",
"destination": "/.well-known/matrix/server",
"content-type": "application/json",
"code":200
},
{
"source": "/.well-known/matrix/client",
"destination": "/.well-known/matrix/client",
"content-type": "application/json",
"code":200
}
]
}
}
$ firebase deploy
=== Deploying to 'dh'...
i deploying hosting
i hosting[dh]: beginning deploy...
i hosting[dh]: found 19 files in public
✔ hosting[dh]: file upload complete
i hosting[dh]: finalizing version...
✔ hosting[dh]: version finalized
i hosting[dh]: releasing new version...
✔ hosting[dh]: release complete
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/dh/overview
Hosting URL: https://dh.firebaseapp.com
$ curl -v https://domain.tld/.well-known/matrix/client 2>&1 | grep content-type
< content-type: application/octet-stream
您得到的答案不正确。您需要指定 custom headers:
{
"hosting": {
"headers": [
{
"source": "/.well-known/matrix/*",
"headers": [
{"key": "Content-Type", "value": "application/json"}
]
}
]
}
}
对于 Matrix 家庭服务器(在 Modular.im 上),您需要 2 个文件:
domain.tld/.well-known/matrix/server
domain.tld/.well-known/matrix/client
...它们还需要 application/json
而不是 firebase 默认的 application/octet-stream
。我该如何更改?
目前firebase.json
的解决方案来自this answer。
$ cat firebase.json
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/.well-known/matrix/server",
"destination": "/.well-known/matrix/server",
"content-type": "application/json",
"code":200
},
{
"source": "/.well-known/matrix/client",
"destination": "/.well-known/matrix/client",
"content-type": "application/json",
"code":200
}
]
}
}
$ firebase deploy
=== Deploying to 'dh'...
i deploying hosting
i hosting[dh]: beginning deploy...
i hosting[dh]: found 19 files in public
✔ hosting[dh]: file upload complete
i hosting[dh]: finalizing version...
✔ hosting[dh]: version finalized
i hosting[dh]: releasing new version...
✔ hosting[dh]: release complete
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/dh/overview
Hosting URL: https://dh.firebaseapp.com
$ curl -v https://domain.tld/.well-known/matrix/client 2>&1 | grep content-type
< content-type: application/octet-stream
您得到的答案不正确。您需要指定 custom headers:
{
"hosting": {
"headers": [
{
"source": "/.well-known/matrix/*",
"headers": [
{"key": "Content-Type", "value": "application/json"}
]
}
]
}
}