firebasefirebase-storagefirebase-dynamic-linksshort-url

Firebase Dynamic Links seems to (re)format the target link?


The users of my app can generate some files and store them in a Firebase Storage bucket. The link to the file looks like this:

https://firebasestorage.googleapis.com/v0/b/myApp/users%2FuserID%2Ffile.mp3?alt=media&token=xxxx-xxxx-xxxx

This is a link with token, so publicly accessible. Now I want to use a short link based on a custom domain, and I use the Dynamic links for this. I am able to successfully generate a short link with the Dynamic Links REST API (mydomain.com/link/xxxxxxxxxx). However, when I follow the short link, I end up redirected on a link like below:

https://firebasestorage.googleapis.com/v0/b/myApp/users/userID/file.mp3?alt%3Dmedia&token=xxxx-xxxx-xxxx

Note the '%2F' in the first link that became '/' in the final one, and the 'alt=' that became 'alt%3D'. This is enough for the link not to work anymore, as I get the message:

{
  "error": {
    "code": 400,
    "message": "Invalid HTTP method/URL pair."
  }
}

Visibly, it's a URL encoding issue happening during the dynamic link redirection. I am 'POST'ing to the Dynamic Link API exactly the first link, but somehow its encoding is altered somewhere in the process. But I could not find any documentation mentioning such thing, and I don't see any parameter that would cause this, therefore I am left with no solution so far...

Anyone with an idea, please?


Solution

  • I ended up re-processing the links resulting from the dynamic links to correct them (e.g. replacing the 'alt%3D' by 'alt=') in Javascript before using them in GET requests.

    I can afford this workaround because the parts of the links that change are pretty much always the same.