electron app - auto find port

This commit is contained in:
Jan Prochazka
2020-04-10 21:21:57 +02:00
parent ac97344c1e
commit 5030c673e6
12 changed files with 88 additions and 56 deletions

View File

@@ -0,0 +1,19 @@
export default function resolveApi() {
if (window.require) {
const electron = window.require('electron');
if (electron) {
const port = electron.remote.getGlobal('port');
return `http://localhost:${port}`;
}
}
// eslint-disable-next-line
const apiUrl = process.env.REACT_APP_API_URL;
if (apiUrl) {
if (apiUrl == 'ORIGIN') return window.location.origin;
return apiUrl;
}
return 'http://localhost:3000';
}