Below is the code to do it.
import { app, BrowserWindow, ipcMain, session } from 'electron';
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
console.log('setting headers in main.dev.js details ', details)
console.log('setting headers in main.dev.js callback ', callback)
details.requestHeaders['Origin'] = 'https://origin.com';
callback({ cancel: false, requestHeaders: details.requestHeaders });
})
references:
https://github.com/electron/electron/issues/2245
https://github.com/electron/electron/issues/6859
import { app, BrowserWindow, ipcMain, session } from 'electron';
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
console.log('setting headers in main.dev.js details ', details)
console.log('setting headers in main.dev.js callback ', callback)
details.requestHeaders['Origin'] = 'https://origin.com';
callback({ cancel: false, requestHeaders: details.requestHeaders });
})
references:
https://github.com/electron/electron/issues/2245
https://github.com/electron/electron/issues/6859
No comments:
Post a Comment