【发布时间】:2018-09-10 00:26:04
【问题描述】:
让我解释一下情况(请原谅我的英语,我会尽力而为):
我的 Firebase 控制台中有两个 Firebase Web 项目:coretechtest-ce207 和 agon-plugin
coretechtest-ce207 是主应用程序,agon-plugin 是辅助应用程序,需要连接到 coretechtest-ce207 的身份验证和数据库。据我所知,我不能在同一个项目上托管两个应用程序,所以这就是我制作单独项目的原因。主要的工作正常,我可以做我想做的一切(注册,数据库等),但我需要在同一个身份验证和数据库上的主要和第二个。 agon-plugin(第二个)基于 FriendlyChat 应用程序制作,并直接连接到托管该应用程序的服务器。 例如:
// Initializes FriendlyChat.
function FriendlyChat() {
this.initFirebase();
}
// Sets up shortcuts to Firebase features and initiate firebase auth.
FriendlyChat.prototype.initFirebase = async function() {
// Shortcuts to Firebase SDK features.
this.auth = firebase.auth();
this.database = firebase.database();
this.storage = firebase.storage();
// Initiates Firebase auth and listen to auth state changes.
await this.auth.onAuthStateChanged(this.onAuthStateChanged.bind(this));
};
如你所见,不需要放
apiKey: "AIzaSyAfGm_ILVdfsd--Fw7aascc8tAB73q__Bbko",
authDomain: "coretechtest-ce207.firebaseapp.com",
databaseURL: "https://coretechtest-ce207.firebaseio.com",
projectId: "coretechtest-ce207",
storageBucket: "coretechtest-ce207.appspot.com",
messagingSenderId: "994718782"
我尝试使用这些参数替换它,所以它会是
FriendlyChat.prototype.initFirebase = async function() {
// Shortcuts to Firebase SDK features.
this.auth = 'coretechtest-ce207.firebaseapp.com';
this.database = 'https://coretechtest-ce207.firebaseio.com';
this.storage = 'coretechtest-ce207.appspot.com';
// Initiates Firebase auth and listen to auth state changes.
await this.auth.onAuthStateChanged(this.onAuthStateChanged.bind(this));
};
但是没有运气,你能告诉我我做错了什么吗?我认为替换它会连接到我的主要项目,但它没有...... =/ 我希望你能明白我想说什么!
谢谢!
【问题讨论】:
标签: javascript firebase