iosangularazureazure-static-web-appapple-app-site-association

Apple App Site Association conflicting with angular route


Can someone shed some light on how to setup iOs app link to work for angular ? Basically I want to have a link in mail sent to users that then opens the app if it is installed.

I have in the src/.well-known folder added a file called 'apple-app-site-association' with no extension.

When running locally it correctly downloads the file when i go to localhost:4200/.well-known/apple-app-site-association

I have also in the angular.json added "src/.well-known" to the assets.

The web app is deployed to azure static web app, and here when I access the site https://APPNAME.com/./well-known/apple-app-site-association it does not work.

I have also checked apples own tool. https://app-site-association.cdn-apple.com/a/v1/PAGE.com

from reading all over related issues it seems that angular sees /apple-app-site-association as a route and not a .json file and I need to add a MIME type to this?

How do I make the browser understand that this is a file and not a route? do I have to change this in angular somewhere, or do I have to do something in azure static web app?


Solution

  • Thanks to Sampath I found a solution.

    If anyone else wants the answer specifically for azure static web app here goes:

    With the inspiration from this post I added the apple-app-site-association.json with extenstion to the path so it looks like this: ./well-known/apple-app-site-association.json

    Then I created a file staticwebapp.config.json in the root folder of the angular project containing:

    {
        "trailingSlash": "auto",
        "routes": [
          {
            "route": "/.well-known/apple-app-site-association",
            "rewrite": "/.well-known/apple-app-site-association.json"
          }
        ],
        "mimeTypes": {
          ".json": "application/json"
        }
      }
    

    Update angular.json to add the config file to the assets array.

    "assets": [
                {
                  "glob": "./staticwebapp.config.json",
                  "input": "./",
                  "output": "/"
                },
                "src/favicon.ico",
                "src/.well-known",
                "src/assets",
                "src/routes.json"
              ],