sindresorhus / electron-serve

Static file serving for Electron apps
MIT License
437 stars 34 forks source link

how to handle cors at production mode ? #22

Closed andyTsing closed 4 years ago

andyTsing commented 4 years ago
if (isProd) serve({ directory: 'app' });
else app.setPath('userData', `${app.getPath('userData')} (development)`);

(async () => {
    await app.whenReady();

    mainWindow = createWindow('main');
    if (isProd) mainWindow.loadURL('app://./home.html');
    else {
        const port = process.argv[2];
        console.log(this.state.port);
        mainWindow.loadURL(`http://localhost:${port}/home`);
    }
            ...
})();

================================================== The above is my code snippet, in production mode, reporting cross-domain issues