问题
I'm implementing Universal Links on iOS 9+ and am trying to add the apple-app-site-association file to my Firebase Hosting root:
https://developer.apple.com/library/ios/documentation/Security/Reference/SharedWebCredentialsRef/
If your app runs in iOS 9 and later and you use HTTPS to serve the file, you can create a plain text file that uses the application/json MIME type and you don’t need to sign it.
How can I set the MIME type to "application/json"? It looks like the documentation does not list this as a possible content type.
回答1:
Google Firebase Hosting has been updated to include this content type. Just add the declaration to your app config firebase.json.
回答2:
Update your firebase hosting config file "firebase.json" like this; you can provide the content-type, response code as well.
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
},
"hosting": {
"public": "dist/my_app",
"ignore": [
"firebase.json",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
},
{
"source": "/.well-known/assetlinks.json",
"destination": "/.well-known/assetlinks.json",
"content-type": "application/json",
"code":200
}
]
}
}
来源:https://stackoverflow.com/questions/38619572/set-file-mime-type-on-firebase-hosting