Dynamic Link Issue in Firebase Hosting and Angular

Viewed 758

We are currently working on an Angular website which also supports an Android Application, during our first development we were able to configure dynamic link and it works well between the Angular and the Android Application.

There is a new update we did on the angular.

Some hours after deployment I noticed the Dynamic Link is no longer working, I noticed the firebase.json file has been overwritten during deployment. I change the Firebase.json file and since then the Dynamic Link is no longer working, all my dynamic links URL is redirecting me to my Angular custom 404 pages, the dynamic link URL is not even changing.

The web application is developed using Angular and deployed on Firebase hosting This is my firebase.json

{
  "hosting": {
    "public": "dist/zealweb",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
        "appAssociation": "AUTO",
        "rewrites": [
            {
                "source": "**",
                "destination": "/index.html"
            },
            {
                "source": "/getstarted/**",
                "dynamicLinks": true
            },
            {
                "source": "/preview/**",
                "dynamicLinks": true
            }
        ]
  }
}

To reproduce the error, visit this link https://gotozeal.com/home/viewdetails/ngFKiFSP05M8QdCv8aeo

Click on the share icon, to generate a dynamic link e.g https://gotozeal.com/preview/2u4knWADHvX6WpdSA

The dynamic link is supposed to open play store while on mobile but on web it will take you directly to the website content.

1 Answers

So far, I was able to get it right on the gotozeal app. I played around with the hosting JSON file and in the end, I was able to resolve the issue by moving the initial **source: **** down the rewrites rule and it worked perfectly.

Not sure if this is the best solution, but so far we have been getting our desired results.

{
  "hosting": {
    "public": "dist/zealweb",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
        "appAssociation": "AUTO",
        "rewrites": [
            {
                "source": "/getstarted/**",
                "dynamicLinks": true
            },
            {
                "source": "/preview/**",
                "dynamicLinks": true
            },
            {
                "source": "**",
                "destination": "/index.html"
            }
        ]
  }
}
Related