diff --git a/desktop/static/main.ts b/desktop/static/main.ts index 13b5977ad..841828cab 100644 --- a/desktop/static/main.ts +++ b/desktop/static/main.ts @@ -16,6 +16,7 @@ import { ipcMain, Notification, globalShortcut, + session, } from 'electron'; import path from 'path'; import url from 'url'; @@ -191,6 +192,7 @@ app.on('ready', () => { } appReady = true; app.commandLine.appendSwitch('scroll-bounce'); + configureSession(); tryCreateWindow(); // if in development install the react devtools extension if (process.env.NODE_ENV === 'development') { @@ -205,6 +207,21 @@ app.on('ready', () => { }); }); + +function configureSession() { + session.defaultSession.webRequest.onBeforeSendHeaders( + { + urls: ['*://*/*'], + }, + (details, callback) => { + // setting Origin to always be 'localhost' to avoid issues when dev version and release version behaves differently. + details.requestHeaders.origin = 'https://localhost:3000'; + details.requestHeaders.referer = 'https://localhost:3000/index.dev.html'; + callback({cancel: false, requestHeaders: details.requestHeaders}); + }, + ); +} + app.on('will-quit', () => { globalShortcut.unregisterAll(); });