fix: use correct protocol for app URL and suppress DevTools in production
- Use app_base_url from the device record directly instead of always falling back to localhost; use https for real domains and http for localhost dev URLs only. - Suppress DevTools in packaged .app builds (app.isPackaged check) so they only open during development.
This commit is contained in:
@@ -29,17 +29,21 @@ async function createWindow() {
|
||||
},
|
||||
});
|
||||
|
||||
let targetUrl = 'http://demo.localhost:5173';
|
||||
let targetUrl = 'http://demo.localhost:5173';
|
||||
if (cachedFullConfig && cachedFullConfig.native_device) {
|
||||
const device = cachedFullConfig.native_device;
|
||||
const eventId = device.event_id_random || device.event_id;
|
||||
const locationId = device.event_location_id_random || device.event_location_id || '';
|
||||
// Use app_base_url from the device record (e.g. bgh.oneskyit.com).
|
||||
// Fall back to localhost only if nothing is configured — never override a real domain.
|
||||
const host = device.app_base_url || 'demo.localhost:5173';
|
||||
const useHost = (host.includes('localhost')) ? host : 'demo.localhost:5173';
|
||||
targetUrl = `http://${useHost}/events/${eventId}/launcher/${locationId}`;
|
||||
// Use https for real domains; localhost dev URLs stay on http
|
||||
const protocol = host.includes('localhost') ? 'http' : 'https';
|
||||
targetUrl = `${protocol}://${host}/events/${eventId}/launcher/${locationId}`;
|
||||
}
|
||||
|
||||
mainWindow.webContents.openDevTools();
|
||||
// Only open DevTools in development (not in a packaged .app build)
|
||||
if (!app.isPackaged) mainWindow.webContents.openDevTools();
|
||||
mainWindow.loadURL(targetUrl).catch(() => {
|
||||
mainWindow?.loadURL('https://dev-demo.oneskyit.com/');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user