Serving Apple App Site Association file using Nginx for React Apps

Designed by Aarthi

The AASA (short for apple-app-site-association) is a file that lives on your website and associates your website domain with your native app. In other words, it’s a safe way to prove domain ownership to iOS for deep linking.

There is no way to serve the apple-app-site-association from a react app. So we have to push the AASA file from the Nginx server.

Copy the AASA file apple-app-site-association.json or apple-app-site-association.applescript file to a particular location in the server.

I have uploaded the file in the following directory

/var/www/certificates/ios/

Go to the file where the Nginx config is written. Its usually in /etc/nginx/sites-enabled/default. To open the file, try the following commands in terminal

cd /etc/nginx/sites-enabled/sudo vim default

Add the following config to the Nginx configuration file above the line where you find this location / {

location /apple-app-site-association {
alias /var/www/certificates/ios/;
index apple-app-site-association.json
autoindex on;
}

To check if your Nginx configuration is correct, run the below command in a terminal

nginx -t

If you get the following output then you are good to go. Else, there is something wrong with your Nginx server configuration.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Now, restart the Nginx server for the changes to take effect.

sudo service nginx restart

Now when to try to visit the route /apple-app-site-association you will be served the apple-app-site-association.json file

https://example.com/apple-app-site-association

The complete default file is given below

Hooray!!, Now you can provide domain ownership for apple using the AASA file.

Say Hi, It’s free at @matheswaaran_S or https://matheswaaran.com

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store