Unable to add Firebase Dynamic Links to a project using a custom domain

I had the same issue and got the same error. The problem was that I was redirecting all the routes to index.html. The solution was to restrict the routes to index.html by exclusion.

"rewrites": [
  {
    "source": "/link/**",
    "dynamicLinks": true
  },
  {
    "source": "!/link/**",
    "destination": "/index.html"
  }
]

After deploying the new configuration to Firebase Hosting, I was allowed to use mydomain.com/link as desired.


I had a similar problem with the root (apex) domain. Basically, if the prefix (the apex domain in my case) is a URL that gives 200 status response, it won't be accepted. In my case the there was an index.html file inside the public folder. I renamed it to something else and it worked.

Here's my firebase.json:

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "appAssociation": "AUTO",
    "rewrites": [ { "source": "/**", "dynamicLinks": true } ]
  }
}

Everything you are doing looks correct with regards to getting your custom domain working. I am wondering if you are using the latest version of firebase-tools (CLI). Custom Domain support for dynamic links was added in version 6.5.0.

Good news is that page.link support still exists but is not as obvious in the new UI flow. The way to get a page.link domain is to start typing your desired subdomain and a suggestion should pop up in the UI. I have included a screenshot to show how this would work.

Adding page link domain image enter image description here

Hope this helps,

Jeff


For us the issue was that we we're using the default Firebase Hosting site for serving our web-app at all routes ("/**"). Serving our web-app from a different domain that dynamic links is the way it should be for us, since links should not interfere with the web-app.

To serve links from a different domain than our web-app, I created a new site just for links and attached our custom domain to that site. Now we have two Firebase Hosting sites. The first default one for our web-app and the second one for Firebase Dynamic Links.

After this setting up Dynamic Links with a custom domain attached to the second Firebase Hosting site worked flawlessly. See the screenshot for more details: enter image description here

EDIT1: the web-app's firebase.json as requested by @cocacrave:

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "function": "nuxtApp"
      }
    ]
  }
}

If you are getting this error with subdomain, this solution worked for me:

{
  "hosting": [
    {
      "target": "app",
      "public": "build",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "appAssociation": "AUTO",
      "rewrites": [
        {
          "source": "/**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "links",
      "public": "build",
      "ignore": [
        "**"
      ],
      "appAssociation": "AUTO",
      "redirects": [
        {
          "source": "/",
          "destination": "{{your domain}}",
          "type": 302
        }
      ],
      "rewrites": [
        {
          "source": "/**",
          "dynamicLinks": true
        }
      ]
    },
    {
      "target": "invite",
      "public": "build",
      "ignore": [
        "**"
      ],
      "redirects": [
        {
          "source": "/",
          "destination": "{{your domain}}",
          "type": 302
        }
      ],
      "appAssociation": "AUTO",
      "rewrites": [
        {
          "source": "/**",
          "dynamicLinks": true
        }
      ]
    }
  ]
}