69

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.

6 Answers 6

59

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.example/link as desired.

8
  • 1
    That was it! Should be stated in the help on firebase when encountering the error really.
    – oldwizard
    Oct 23, 2019 at 6:59
  • 1
    ‘!’ symbol works as negation; URLs which NOT (!) begin with (/link/**) are redirected to index.html. Mar 30, 2020 at 3:16
  • 1
    This really helps! Thanks Erik!
    – damingzi
    Jul 7, 2020 at 4:23
  • 1
    What a shame, The best answer is at the bottom.
    – JIE WANG
    Apr 17, 2021 at 7:51
  • 1
    How does this work if you want multiple dynamic link routes that start with different prefixes? Is there a negation (!) + OR syntax? i.e. "source": "!/linka|linkb/**",
    – mattgabor
    Jul 13, 2022 at 17:40
32

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 } ]
  }
}
6
  • 2
    That helped me A LOT! Thank you so much... Solution: rename index.html to something else
    – AZOM
    Feb 4, 2020 at 15:18
  • You have saved my life! This answer should be the accepted answer!
    – dshukertjr
    Sep 9, 2020 at 4:42
  • 3
    Don't forget to rename your file back to index.html after setup to avoid 404 error for your website Dec 16, 2020 at 12:35
  • This Really works, you saved me, thank you May 13, 2021 at 6:25
  • Thank you! Worked for me. If I change the name of index.html back and deploy, will there be any issues with the dynamic link? Jun 1, 2021 at 16:32
18

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

8
  • 3
    Oh that's interesting! Thank you, I hadn't noticed page.link in that pop up. Also I didn't see anything in the custom domain docs about needing a certain version fo the Firebase CLI. I was using firebase-tools 6.3.0. I'll give 6.5.0 a shot.
    – Splaktar
    Mar 15, 2019 at 18:11
  • 1
    Deploying to Hosting with firebase-tools 6.5.0 seems to have fixed this! It's odd that the docs don't mention this, nor the Firebase Console, and that the CLI didn't complain when I tried to deploy something incompatible with Firebase CLI 6.3.0.
    – Splaktar
    Mar 15, 2019 at 18:13
  • 1
    This got me farther, but then I hit this issue: twitter.com/Splaktar/status/1106621875755642880?s=19
    – Splaktar
    Mar 15, 2019 at 19:10
  • 1
    That is not expected and I have pinged the team to see if we can get a quick resolution for you.
    – Jeff Avis
    Mar 15, 2019 at 20:02
  • 1
    I was able to get it to work with my www.devintent.com domain, but not with devintent.com. In the Hosting console, I have a redirect from devintent.com -> www.devintent.com.
    – Splaktar
    Mar 15, 2019 at 20:27
6

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"
      }
    ]
  }
}
2
  • 1
    I've done the same thing but I don't know if something is wrong with my firebase.json config. I try to create the Dynamic Links URL prefix on the subdomain (created just for the links) and I get the big red flag to edit my config. Do you mind updating your answer with the config you used?
    – cocacrave
    Mar 16, 2020 at 6:27
  • This worked like a charm. I didn't need to add anything to my firebase.json. Just creating a new site, then selecting it when creating the DL was good enough. For setting up Auth, I had to manually enter the /__/auth/action path tho, as it did not come up in suggestions.
    – Chad Mx
    Jul 26, 2020 at 17:41
2
"appAssociation": "AUTO",
"rewrites": [
  {
    "source": "/page/**",
    "destination": "/index.html"
  },
  {
    "source": "/link/**",
    "dynamicLinks": true
  }
]

It works! I guess the error caused by the original config of "source":"**". May be the range is too large? Though doc say "/__/*" have high priority. (https://firebase.google.com/docs/hosting/full-config?authuser=0#hosting_priority_order)

2

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
        }
      ]
    }
  ]
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.