使用自定义域的 Firebase 身份验证 - 选择我的 Google 帐户后出现空白页面

Eny*_*iny 8 firebase firebase-hosting firebase-authentication

我正在为我的网络应用程序使用 Firebase 身份验证,并为 Firebase 身份验证的 Google 登录功能自定义重定向域,以便 Google 的身份验证页面将显示Continue to: mydomain.io

我遵循了Firebase 的文档

  1. 域名托管

Firebase 托管

Cloudflare 配置

  1. 添加auth.mydomain.io到 Firebase 控制台中的授权域列表

Firebase 控制台授权域

  1. 在 Google OAuth 设置页面中,将重定向页面的 URL 列入白名单https://auth.mydomain.io/__/auth/handler

谷歌 OAuth 客户端

  1. 编辑我的应用程序的 JavaScript 代码:
const firebaseConfig = {
 ...
 authDomain: "auth.mydomain.io",
 ...
}
Run Code Online (Sandbox Code Playgroud)

在本地运行我的应用程序,我可以看到我的域已正确链接到我的应用程序。

登录:继续访问 mydomain.io

但是,当我选择要连接的 Google 帐户时,没有任何反应。在弹出窗口中,我被重定向到auth.mydomain.io一个空白页面和顶部的无限加载栏

编辑:我使用 Facebook OAuth 也遇到同样的问题

选择账户后

大约 10 秒后,弹出窗口自行关闭,我在本地应用程序控制台中收到以下错误:

FirebaseError: Firebase: Error (auth/popup-closed-by-user).
    at createErrorInternal (assert.ts:122:1)
    at _createError (assert.ts:83:1)
    at popup.ts:283:1
Run Code Online (Sandbox Code Playgroud)

当我将应用程序的 JavaScript 配置更改为myapp.firebaseapp.com属性时authDomain,它工作正常,我可以使用我的谷歌帐户登录

const firebaseConfig = {
 ...
 authDomain: "myApp.firebaseapp.com",
 ...
}
Run Code Online (Sandbox Code Playgroud)

Eny*_*iny 1

带着一些好消息回来。现在它工作得很好,尽管我没有改变任何东西。如果你和我的情况一样的话,给它24小时到48小时。