In order to set up universal links for an iOS app, I have created an apple-app-site-association file, and placed it in the /public directory of my Rails app.
I can curl it at the correct address, but it returns the wrong content type. Instead of application/json
or application/pkcs7-mime
it returns application/octet-stream
, as you can see in the response here:
curl -i https://example.com/apple-app-site-association
HTTP/1.1 200 OK
Server: nginx/1.10.1
Content-Type: application/octet-stream
Content-Length: 245
Last-Modified: Mon, 21 Nov 2016 12:45:00 GMT
Strict-Transport-Security: max-age=31536000
{
"applinks": {
"apps": [],
"details": [
{
"appID": "APPPREFIX.com.mycompany.app",
"paths": [
"/home*"
]
}
]
}
I am attempting to specify a Content-Type in the nginx configuration:
/etc/nginx/sites/sites-available/sitename:
server {
...
location /apple-app-site-association {
default_type application/pkcs7-mime;
}
}
I have saved this change and restarted nginx. This doesn't make any difference to the response from curl. I've also tried location /public/apple-app-site-association {}
and a few other variations, to no effect.
What is the correct way to set up nginx to deliver this file with the correct content type?
This worked for me within .htaccess:
<FilesMatch "apple-app-site-association">
ForceType application/json
</FilesMatch>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With