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

Splaktar picture Splaktar · Mar 15, 2019 · Viewed 10.1k times · Source

I've created Firebase Dynamic Links in other projects before using the page.link URL prefix (the only option at the time). However that no longer appears to be an option when enabling Dynamic Links for a new project today. It looks like the docs for custom domains were updated today. Unfortunately, while they provide some helpful examples, they don't explain how to resolve my issue in a way that I can understand.

error configuring dynamic links for custom domain

So this message seems to indicate that I need to "Put links under a subpath". It seems to me that adding the /link path prefix here should accomplish that? But after making that change, I get the same error message.

It looks like you already have content served on this Hosting site. Put links under a subpath to avoid conflicts with existing content.

I order to try to work around this, I went to my project and added the suggested Hosting configuration and deployed it.

firebase.json:

{
  "hosting": {
    "public": "dist",
    "ignore": [
      "**/.*"
    ],
    "appAssociation": "AUTO",
    "rewrites": [
      {
        "source": "/link/**",
        "dynamicLinks": true
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

Even after waiting an hour, I keep getting the same error and I don't understand what to do.

Note that I have the rewrite to /index.html because I have an Angular Single Page Application hosted at www.devintent.com.

No matter what I do, I keep getting this error and the Continue button stays disabled. I tried using my naked domain devintent.com instead of www.devintent.com, but that didn't help. I tried using links.devintent.com, but got the same error.

If I manually remove disabled from the Continue button, then I get this error message:

configure path prefix manually message This links to the docs for manually configuring hosting for dynamic links which has some steps that I've already completed. Clicking the Check Again button just takes me back to the same error in the first image above.


Workaround to not use Custom Domains

I'm happy at this time to use a page.link link, I just need to create a Dynamic Link and get unblocked on this task, but I can't figure out any way in the console to allow me to do that either.

Update on this: I figured out that I needed to add the subdomain to the page.link URL. The tooltip says "or a free Google-provided domain (for example, yourapp.page.link)" at the end. This is a little less prominent that I would have liked (as I didn't find it for quite a long time). Using devintent.page.link works for me as a workaround for now.


However, I'm not sure why the Custom Domain configuration didn't work and why it would be the default if there are such complications with projects with existing Hosting configurations and custom domains.

Answer

Erik Martín Jordán picture Erik Martín Jordán · Oct 21, 2019

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.