Search code examples
firebasefirebase-authenticationfirebase-hostingfirebase-dynamic-links

Dynamic Links Custom Path not applied in Firebase Authentication


I have setup Firebase Dynamic Links with an URL in the following format: a.b.c/d

However, emails sent by Firebase Authentication contain Dynamic Links of the format a.b.c/?link=... instead of a.b.c/d/?link=..., which means that they do not work.

I followed this guide / this guide to send the links.

Whenever I manually copy the link and add d/ in the URL, the Dynamic Links will work since Dynamic Links is set up this way in Firebase Console and also in firebase.json for Firebase Hosting.

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

Solution

  • Unfortunately, Firebase Authentication does not yet support custom paths in Dynamic Links as bojeil pointed out (confirmed by Firebase support).
    Unfortunately, capturing URL segments in Firebase Hosting redirects does not support query parameters, which would be required to redirect /?link=... to /d/?link=....

    Because of these two unfortunate circumstances, I simply used some JavaScript to redirect any request to /?link=... to /d/?link...:

    const link = new URLSearchParams(window.location.search).get('link')
    if (window.location.pathname == '/' && link != null && link != '') window.location = `a.b.c/d/${window.location.search}`