Dav*_*veJ 14 html javascript firebase electron
我正在尝试使用Firebase和Electron.当我在网页上安装它时,它不起作用,因为Electron页面是本地托管的,没有hostname.这是我得到的错误......
Uncaught Error: This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.
Run Code Online (Sandbox Code Playgroud)
我无法将空(或通配符)授权域添加到Firebase控制台,因此我卡住了.有没有人对如何解决这个问题有任何想法?
编辑:这是我正在使用的代码,它只是标准的样板,没有什么额外的......
<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
<script>
var config = {
apiKey: "AIzaSyBvmmPB0_Oddc-02cUj3Ntt3wi8jSxxxx",
authDomain: "xxxxx-d24ad.firebaseapp.com",
databaseURL: "https://xxxxx-d24ad.firebaseio.com",
storageBucket: "",
};
firebase.initializeApp(config);
</script>
Run Code Online (Sandbox Code Playgroud)
小智 6
现在,您可以通过从配置中删除authDomain行来抑制此错误.Auth signInWithPopup/signInWithRedirect操作需要authDomain,但其他一切都应该有效.
只有在您实际尝试执行signInWithPopup/Redirect时才会抛出该错误的库版本正在运行中.
我不知道这是否是最好的解决方案,但这是一种解决方法。
使用简单的快递服务器创建文件server.js
“ server.js”
var express = require('express');
var http = require('http');
var path = require('path');
var appServer = express();
appServer.use(express.static(path.join(__dirname, '')));
appServer.get('*', (req, res) => {
res.sendFile(__dirname + 'index.html');
});
http.createServer(appServer).listen(3007, function() {
console.log('Express server listening on port');
});
Run Code Online (Sandbox Code Playgroud)
在您的main.js(electron-main-js-file)中
在main.js的顶部启动节点服务器
require('./server');
Run Code Online (Sandbox Code Playgroud)
并更改“ win.loadURL”
win.loadURL('http://localhost:3007');
Run Code Online (Sandbox Code Playgroud)
我已经分叉了您的项目并实施,firebase的错误已消失,但jQuery未定义,我想您可以修复它。
https://github.com/diegoddox/sad-electron-firebase-error