androidfirebasejekyllfirebase-hostingtwa

Empty dynamic link assetlinks.json issue when using firebase hosting


The response of https://evrcare.co/.well-known/assetlinks.json is coming [] instead of valid json.
I've put the correct assetlinks.json file inside .well-known folder.
What happens now is that my TWA shows a url bar (which is not supposed to if response of https://evrcare.co/.well-known/assetlinks.json is correct json).
However, I can see complete json if I put assetlinks.json in some other folder than .well-known like : https://evrcare.co/well-known/assetlinks.json

So I looked over the internet and they suggested couple of ways, none of them worked. like:

1) Create another folder well-known and put assetlinks.json and then redirect:

firebase.json:

 {
        "source": "/.well-known/assetlinks.json",
        "destination": "/well-known/assetlinks.json"
      }

Didn't work. response: []

2) add header as application/json for **/.well-known/**

firebase.json:

 "headers": [
          {
            "key": "Cache-Control",
            "value": "no-store"
          },
          {
            "key": "Expires",
            "value": "0"
          },
          {
            "key": "Pragma",
            "value": "no-cache"
          }
        ]
      },
      {
        "source": "**/.well-known/**",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]
      }
    ]

Didn't work. response []

3) add "appAssociation": "NONE" to firebase.json.

Didn't work. I get page not found.

4) add "dynamicLinks": true to "rewrites"

firebase.json:

"rewrites": [
  {
    "source": "/**",
    "dynamicLinks": true
  }
],

Didn't work. response: []


You can test https://evrcare.co/.well-known/assetlinks.json and https://evrcare.co/well-known/assetlinks.json with my current firebase.json config:

{
  "hosting": {
    "public": "_site",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "/bigben",
        "function": "bigben"
      },
      {
        "source": "**",
        "destination": "/index.html"
      },

      {
        "source": "/.well-known/assetlinks.json",
        "destination": "/well-known/assetlinks.json"
      }
    ],
    "cleanUrls": true,
    "headers": [
      {
        "source": "**",
        "headers": [
          {
            "key": "Cache-Control",
            "value": "no-store"
          },
          {
            "key": "Expires",
            "value": "0"
          },
          {
            "key": "Pragma",
            "value": "no-cache"
          }
        ]
      },
      {
        "source": "**/.well-known/**",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]
      }
    ]
  },

  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  },
  "emulators": {
    "functions": {
      "port": 5001
    },
    "firestore": {
      "port": 8080
    },
    "hosting": {
      "port": 5000
    }
  }
}

I followed https://appmaker.xyz/pwa-to-apk/ to create TWA and assetlinks.json file.

firebase-tools: 8.0.2

Platform: Windows


Example of a valid JSON: https://google.com/.well-known/assetlinks.json

Tools to verify linking:


Solution

  • I'm dumb. My build tool (jekyll) was ignoring folders which start with dot.

    Had to add this to my _config.yml to make it work:

    # Folders with dotfiles are ignored by default.
    include: [.well-known]