Serving apple-app-site-association file for Apple Universal links

Serving apple-app-site-association file for Apple Universal links

Serving apple-app-site-association file for Apple Universal links 150 150 Benjamin Durin

An iOS app I am writing an API for is using Apple Universal links. For this feature to work, the server must serve a JSON file called apple-app-site-association but without an extension.

Problem: NGINX serves this file as application/octet-stream while iOS is expecting an application/json MIME type.

I tried forcing the type for this file in the config file but nothing that I googled worked.

Finally I decided to rename the file to apple-app-site-association.json in order to have the correct MIME type automatically set, but knowing that iOS would take nothing of that I added a rewrite rule. This rewrite rule serves the apple-app-site-association.json file when the apple-app-site-association file is requested:

rewrite /.well-known/apple-app-site-association /.well-known/apple-app-site-association.json;