16

I'm using Firebase Dynamic Links to redirect users to mobile app.

Links like https://example.com/mypath works, but I also want to use root url, i.e. https://example.com

Currently it shows error:

Invalid Dynamic Link

Requested URL (https://example.com/) must be a parsable and complete DynamicLink.

If you are the developer of this app, ensure that your Dynamic Links domain is correctly configured and that the path component of this URL is valid.

When I try to set up a link without prefix, it shows error:

Short URL is required

Is it any way to set up root url?

Pavel
  • 5,374
  • 4
  • 30
  • 55
  • What's the purpose of using root domain. Suppose if u hit the url www.example.com in your mobile browser It should open your website instead of your mobile app. I think that would be the right behaviour. – Sandeep Nov 25 '19 at 07:41
  • @Sandeep while example.com opens website, I want to make app.example.com opens mobile app. That's why I need root domain – Pavel Nov 25 '19 at 13:41
  • the app.example.com also represent a url to a blog where example.com is the domain. So you can't use it as a dynamic link in firebase. Expected url is app.example.com/app – Sandeep Nov 28 '19 at 07:16
  • @Sandeep what do you mean by "blog"? My site doesn't have a blog. The url app.example.com is already handled by firebase dynamic links. But firebase shows error I posted in the question – Pavel Nov 29 '19 at 10:11
  • You need to understand the components of URL. any thing such as www.example.com or www.app.example.com is know as hostname and subdomain. Therefore to create a dynamic link with a deep link you need to provide a PATH name followed by *example.com/APP. In the pic you have used slash /, which will not work you need to provide a string (PATH) over there. Without that dynamic link cannot be created – Sandeep Nov 29 '19 at 17:06
  • @Sandeep in my understanding slash / doesn't work not because URL limitations but because lack of firebase support – Pavel Nov 29 '19 at 17:45
  • Yes that's what I said – Sandeep Nov 29 '19 at 21:37
  • Well, now I've got it, thanks – Pavel Nov 29 '19 at 22:19
  • 1
    @Pavel I wondered if you managed to fix this issue, as I am facing this same issue – bastami82 Nov 15 '20 at 14:33

5 Answers5

3

Another way to set up a redirect from the root dynamic link domain (without serving a page with a javascript redirect) is by adding a redirect rule like this one to your firebase.json file:

"redirects": [ {
      "source": "/",
      "destination": "https://example.com/page-for-root-to-redirect-to",
      "type": 301
    } ]

This rule will exist alongside your dynamic link rewrite rule(s), so for a simple setup where all paths except the root are treated as dynamic links, your firebase.json might look like this:

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [ {
      "source": "/**",
      "dynamicLinks": true
    } ],
    "redirects": [ {
      "source": "/",
      "destination": "https://example.com/page-for-root-to-redirect-to",
      "type": 301
    } ]
  }
}

To access and modify your firebase.json file, you'll have to set up firebase hosting with the Firebase CLI if you haven't already: https://firebase.google.com/docs/hosting

This page explains more about the firebase.json file and how to use rewrite and redirect rules: https://firebase.google.com/docs/hosting/full-config

1

If you also happen to use Cloudflare, my solution to this problem was to add a subdomain to Firebase dynamic links and make the main url redirect to the subdomain using page rules.

This way, you can setup it up to work like this:

  • example.com/url -redirect_to-> subdomain.example.com/url (and load dynamic link)
  • example.com/ -redirect_to-> main site or whatever you want
Peter
  • 96
  • 8
0

I had this same problem. What I wanted to do is forward the root domain to a different URL. What I did was set up firebase hosting on that domain. Then on the index.html file, I wrote a javascript redirect.

<script>
window.location = "https://www.example.com";
</script>

If you need any more help, please feel free to reply to this and I will help you.

Anonoymous
  • 57
  • 8
0

As an Android user, I had sort of same issue, I did manage to get this sorted finally, just in case someone else has the same issue as mine I put what I did:

so if you getting the same issue, which is by typing following in your browser and you do not see any data, then this means your Firebase project is not fully registered with the sha256 key.

 https://YOURLINK.page.link/.well-known/assetlinks.json 

In my case, I had to add a new sha256 key to my firebase project, apparently for dynamic links to work Firebase project MUST be signed with the sha256.

This official firebase video should keep you going: https://youtu.be/zra2DCd0DnY

bastami82
  • 5,955
  • 7
  • 33
  • 44
  • This applies to Android apps only, correct? I'm getting the error on iOS but Firebase settings don't have a place to add SHA to the iOS app, only Android (which is the case in the video you linked also). – Nelu May 03 '21 at 23:05
  • @Nelu sorry for the delayed reply, have no clue what you need to do with iOS tbh, but I assume there must be official iOS videos too. sorry for not being more help here – bastami82 May 10 '21 at 10:11
-2

Requested URL must be a parseable URI, but possibly incomplete to be a DynamicLink.

If you are the developer of this app, ensure that your Dynamic Links domain is correctly configured and that the path component of this URL is valid.