Firebase 如何将spesific文件的内容类型更改为application/json?
对于Modular.im上的Matrix homeserver,您需要有2个文件: domain.tld/.well-known/matrix/server domain.tld/.well-known/matrix/client …它们还需要是application/json,而不是firebase的默认application/octet流。我该如何改变这一点 当前firebase.json的not wroking解决方案来自Firebase 如何将spesific文件的内容类型更改为application/json?,firebase,firebase-hosting,Firebase,Firebase Hosting,对于Modular.im上的Matrix homeserver,您需要有2个文件: domain.tld/.well-known/matrix/server domain.tld/.well-known/matrix/client …它们还需要是application/json,而不是firebase的默认application/octet流。我该如何改变这一点 当前firebase.json的not wroking解决方案来自 你得到的答案是不正确的。您需要指定: 你得到的答案是不正确的。您需
你得到的答案是不正确的。您需要指定:
你得到的答案是不正确的。您需要指定:
$ 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
{
"hosting": {
"headers": [
{
"source": "/.well-known/matrix/*",
"headers": [
{"key": "Content-Type", "value": "application/json"}
]
}
]
}
}