14 lines
464 B
Plaintext
Raw Permalink Normal View History

A Content Security Policy helps prevent the injection of malicious content.
Define a CSP that restricts the sources of content that can be loaded by your application.
[source,javascript]
----
mainWindow.webContents.session.webRequest.onHeadersReceived((details, callback) => {
callback({
responseHeaders: {
...details.responseHeaders,
'Content-Security-Policy': ["default-src 'self'; script-src 'self' https://example.com"]
}
});
});
----