Lesson 26 of 28 · javascript
Loading Local HTML, Remote URLs & Custom Protocols
Duration: 8 mins
Loading Local HTML, Remote URLs & Custom Protocols
Local file – most common:
win.loadFile('src/index.html');
Remote URL – be careful with security (CSP, webSecurity):
win.loadURL('https://app.example.com');
Custom protocol – useful for bundlers (e.g., app://):
app.whenReady().then(() => {
protocol.registerFileProtocol('app', (request, callback) => {
const url = request.url.substr(6); // strip "app://"
callback({ path: path.normalize(`${__dirname}/${url}`) });
});
win.loadURL('app://index.html');
});
When loading remote content, disable Node integration and enforce Content‑Security‑Policy headers.