Skip to content

Commit 1e3f59a

Browse files
committed
Fix Electron app black screen issue and rebuild portable exe
- Add CSP meta tag for proper content loading in Electron - Add backgroundColor to prevent flash of unstyled content - Improve error logging in main.js for debugging - Rebuild portable exe with fixes
1 parent 4420cc9 commit 1e3f59a

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

frontend/main.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,46 @@ function createWindow() {
2525
height: 800,
2626
icon: path.join(__dirname, 'build-resources/icon.png'),
2727
title: 'SecureScript',
28+
backgroundColor: '#0F172A',
2829
webPreferences: {
2930
preload: path.join(__dirname, 'preload.js'),
3031
nodeIntegration: false,
3132
contextIsolation: true,
33+
devTools: isDev
3234
},
3335
});
3436

3537
// Determine the correct path to load
36-
const indexPath = isDev
37-
? 'http://localhost:3000'
38-
: `file://${path.join(__dirname, 'build', 'index.html')}`;
38+
let indexPath;
39+
if (isDev) {
40+
indexPath = 'http://localhost:3000';
41+
} else {
42+
// In production, the build folder is at the root level in the packaged app
43+
indexPath = `file://${path.join(__dirname, 'build', 'index.html')}`;
44+
}
3945

4046
console.log('Loading URL:', indexPath);
4147
console.log('__dirname:', __dirname);
4248
console.log('isDev:', isDev);
49+
console.log('app.isPackaged:', app.isPackaged);
4350

44-
win.loadURL(indexPath);
51+
win.loadURL(indexPath).catch(err => {
52+
console.error('Failed to load URL:', err);
53+
});
4554

4655
if (isDev) {
4756
win.webContents.openDevTools({ mode: 'detach' });
4857
}
4958

5059
// Handle load errors
51-
win.webContents.on('did-fail-load', (event, errorCode, errorDescription) => {
52-
console.error('Failed to load:', errorCode, errorDescription);
60+
win.webContents.on('did-fail-load', (event, errorCode, errorDescription, validatedURL) => {
61+
console.error('Failed to load:', errorCode, errorDescription, validatedURL);
62+
console.error('Attempted to load from:', validatedURL);
63+
});
64+
65+
// Log when content is loaded
66+
win.webContents.on('did-finish-load', () => {
67+
console.log('Content loaded successfully');
5368
});
5469
}
5570

frontend/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#0066CC" />
8+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://pankajbind.pythonanywhere.com https://*.pythonanywhere.com;" />
89
<meta
910
name="description"
1011
content="SecureScript - Security compliance and hardening tool for Windows systems"
1.75 KB
Binary file not shown.

0 commit comments

Comments
 (0)