Using Firebase with Electron

后端 未结 4 715
生来不讨喜
生来不讨喜 2020-12-28 08:44

I\'m trying to use Firebase with Electron. When installing it just like I would on a web page it doesn\'t work because Electron pages are hosted locally and don\'t have a

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-28 09:27

    I don't know if this is the best solution but is a workaround.

    create a file server.js with a simple express server

    "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');
    });
    

    In your main.js(electron-main-js-file)

    On the top of the main.js start the node server

    require('./server');
    

    and change the "win.loadURL"

    win.loadURL('http://localhost:3007');
    

    I've fork your project and implement, the error from firebase is gone but jQuery is not defined, I think you can fix that.

    https://github.com/diegoddox/sad-electron-firebase-error

提交回复
热议问题