adjusts electron path to respect protocol and host as well

This commit is contained in:
smacpherson64 2022-08-24 11:43:12 -05:00
parent 6b4e1020a8
commit 1862e3240a
2 changed files with 10 additions and 1 deletions

View File

@ -9,7 +9,11 @@ function createWindow() {
height: 600,
});
mainWindow.loadURL('http://localhost:' + (argv.port ? argv.port : 8000));
const port = argv.port ? argv.port : 8000;
const host = argv.host ? argv.host : 'localhost';
const protocol = argv.protocol ? argv.protocol : 'http';
mainWindow.loadURL(protocol + '://' + host + ':' + port);
}
app.whenReady().then(() => {

View File

@ -7,10 +7,15 @@ export default async function openApp(app: true | string, options: Options) {
if (app === true || app === 'electron') {
try {
const port = options.port ? `--port=${options.port}` : '';
const host = options.host ? `--host=${options.host}` : '';
const protocol = options.protocol ? `--protocol=${options.protocol}` : '';
// eslint-disable-next-line @typescript-eslint/no-var-requires
spawn.sync(require('electron') as string, [
path.join(__dirname, '..', '..', 'app'),
port,
host,
protocol,
]);
} catch (error) {
/* eslint-disable no-console */