Lesson 26 of 28
javascriptLoading Local HTML, Remote URLs & Custom Protocols
8 mins
Course progress93%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 26 of 28
javascript8 mins
Keep these ideas in mind as you work through the lesson.
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.