Set file MIME type on Firebase Hosting

这一生的挚爱 提交于 2019-12-12 00:51:19

问题


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

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