Skip to content

Commit 6982279

Browse files
Merge pull request #6 from glanham-jr/gl/x-frame-interceptor-fix
fix: intercept and remove security headers so remote site can load
2 parents ccc2f0e + cb1b587 commit 6982279

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { app, BrowserWindow, shell, ipcMain } = require("electron");
1+
const { app, BrowserWindow, shell, ipcMain, session } = require("electron");
22
const path = require("path");
33

44
// Import centralized configuration
@@ -292,6 +292,17 @@ function createWindow() {
292292
}
293293

294294
app.whenReady().then(() => {
295+
// Strip X-Frame-Options and CSP frame-ancestors headers so the remote site can load in our iframe
296+
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
297+
const stripped = ['x-frame-options', 'content-security-policy'];
298+
const headers = Object.fromEntries(
299+
Object.entries(details.responseHeaders).filter(
300+
([key]) => !stripped.includes(key.toLowerCase())
301+
)
302+
);
303+
callback({ responseHeaders: headers });
304+
});
305+
295306
createWindow();
296307

297308
app.on("activate", function () {

0 commit comments

Comments
 (0)