动态链接自定义路径未在Firebase身份验证中应用 [英] Dynamic Links Custom Path not applied in Firebase Authentication

查看:88
本文介绍了动态链接自定义路径未在Firebase身份验证中应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了 Firebase动态链接,其URL的格式如下:a.b.c/d

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

但是, Firebase身份验证发送的电子邮件包含格式为a.b.c/?link=...而不是a.b.c/d/?link=...的动态链接,这意味着它们不起作用.

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.

每当我手动复制链接并在URL中添加d/时,由于在Firebase控制台以及firebase.json中为 Firebase托管.

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

推荐答案

不幸的是, Firebase身份验证尚不支持动态链接中的自定义路径,例如 Firebase Hosting 重定向中捕获URL段 a>不支持查询参数,将/?link=...重定向到/d/?link=...可能需要.

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=....

由于这两种不幸的情况,我只是使用了一些 JavaScript 将任何请求从/?link=...重定向到/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}`

这篇关于动态链接自定义路径未在Firebase身份验证中应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆