2

I'm using Firebase Hosting to host a website and I'm using a custom domain name. I want my website to be the destination for let's say: https://example.com

I also use firebase dynamic links that uses the same domain but using a different prefix.

Like this: https://links.example.com

The website host and dynamic links are working fine, but the problem is I don't know how to write my firebase.json rewrites in a way that allows for both the site (example.com) to work and the subdomain (links.firebase.com) that I can use for my dynamic links.

The dynamic links work if I use the following rewrite:

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

But this way the main website (example.com) display a message about not being a valid dynamic link, in stead of showing the index.html

TL/DR I'm wondering if it is possible to have both the website (example.com) and the dynamic links (links.example.com) working on the same domain (example) ?

Thanks in advance

EDIT 1: I had renamed the index.html so that's why I wasn't seeing the website. Now that I changed it back it works, but the dynamic links do not. links.example.com shows the index.html

EDIT 2: It finally works as intented: example.com and links.example.com point to the index.html while any format like links.example.com/aShortDynamicLinkCode activates dynamic links.

I used the following rewrites in my Firebase.json to achieve this

      {
        "source": "**",
        "dynamicLinks": true
      },
      {
        "source": "/**",
        "dynamicLinks": true
      },
Chologism
  • 25
  • 1
  • 5

1 Answers1

0

If you have an index.html in your public directory, it will serve at / even if you have a rewrite like you specify (see serving priority in the docs).

If you're not seeing your index.html, that indicates that something is probably misconfigured. Double-check that your index.html is in the root of your public directory and that the number of files being deployed seems accurate.

Michael Bleigh
  • 25,334
  • 2
  • 79
  • 85
  • Thanks you for the quick response, I had changed the index.html name now that I changed it back the site works, the problem is dynamic links don't "links.example.com" also shows the index.html – Chologism Nov 09 '20 at 19:29
  • Yes, that's correct -- the same site will always serve the same content to all domains connected to it. If that's not the goal, you might want to set up [a second site](https://firebase.google.com/docs/hosting/multisites) for Dynamic Links. – Michael Bleigh Nov 09 '20 at 21:12