Firebase中的自定义authDomain [英] Custom authDomain in Firebase
问题描述
我正在将Firebase的内置oAuth功能用于SPA.
I am using Firebase's built-in oAuth feature for an SPA.
此SPA位于其自己的域中,例如foobar.com
This SPA is on a domain of it's own, say foobar.com
问题是,当打开oauth弹出窗口时,将使用旧的foobar.firebaseapp.com
域,而不是新的foobar.com
域
The problem is, when the oauth popup is opened, the old foobar.firebaseapp.com
domain is used, instead of the new foobar.com
domain
我的初始化看起来像这样
My init looks like this
firebase.initializeApp({
apiKey: '...',
authDomain: 'foobar.firebaseapp.com',
databaseURL: 'https://foobar.firebaseio.com',
storageBucket: 'foobar.appspot.com',
messagingSenderId: '123456'
})
我猜想authDomain
可能与它有关,但是如果将其更改为foobar.com
,则会收到错误消息:
I am guessing authDomain
may have something to do with it, but if I change it to foobar.com
I get the error:
code: "auth/popup-closed-by-user", message: "The popup has been closed by the user before finalizing the operation."}
简而言之,我是否缺少一种为Firebase自定义oAuth网址的方法?
In short, is there a way I am missing to customize the oAuth url for Firebase?
推荐答案
authDomain
依赖于该域上可用的特定脚本.如果您的单页应用程序托管在具有自定义域的Firebase托管上,则您可以将该域用作authDomain
.
The authDomain
relies on specific scripts being available on that domain. If your Single-Page App is hosted on Firebase Hosting with a custom domain, you will be able to use that domain as the authDomain
.
或者,您可以在域的子域上为Firebase Hosting设置自定义域,例如auth.foobar.com
,然后您就可以将auth.foobar.com
用作authDomain
.
Alternatively, you could set up a custom domain for Firebase Hosting on a subdomain of your domain e.g. auth.foobar.com
and you'd then be able to use auth.foobar.com
as your authDomain
.
当前不支持将非Firebase托管域用作您的authDomain
.
There is currently no support for using a non-Firebase-Hosting domain as your authDomain
.
这篇关于Firebase中的自定义authDomain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!