我的网站在 Firebase 实时数据库和跨源资源政策方面存在问题。我的站点已经配置了跨源资源策略标头,并且正在为我站点中的每个资产(js、css、html 等)提供服务。但是现在来自 firebase.io 的 js 脚本被阻止了,因为它没有这个标头。我想问一下,我如何添加这些标题?我应该去 Firebase 控制台的哪个位置?
这是触发问题的一段代码。基本上我初始化Server
对象然后调用changeDb,
然后调用checkAuthor(出现问题的地方):
window.Server = function () {
const config = {
apiKey: FirebaseApiKey,
authDomain: FirebaseAuthDomain,
projectId: FirebaseProjectId,
storageBucket: FirebaseStorageBucket,
messagingSenderId: FirebaseMessagingSenderId,
appId: FirebaseAppId,
databaseURL: FirebaseDatabaseUrl
};
firebase.initializeApp(config);
};
Server.prototype.changeDb = function (prefix) {
this.annotationsRef = firebase.database().ref().child(prefix + '/annotations');
this.authorsRef = firebase.database().ref().child(prefix + '/authors');
}
Server.prototype.checkAuthor = function (authorId, openReturningAuthorPopup, openNewAuthorPopup) {
this.authorsRef.once('value', authors => { //<== Here is where it is triggered
if (authors.hasChild(authorId)) {
this.authorsRef.child(authorId).once('value', author => {
openReturningAuthorPopup(author.val().authorName);
});
} else {
openNewAuthorPopup();
}
});
};