Skip to content

Proxying electron apps #14

@parsiya

Description

@parsiya
// app.commandLine.appendSwitch('proxy-server', 'http://127.0.0.1:8090');
// app.commandLine.appendSwitch('ignore-certificate-errors', 'true');
// app.commandLine.appendSwitch('allow-insecure-localhost', 'true');

app.on('ready', function() {

  mainWindow = new BrowserWindow({ width: 1024, height: 728 });
  mainWindow.webContents.session.setProxy({proxyRules:"http=localhost:8090;https=localhost:8090"}, function() {mainWindow.loadURL('file://' + __dirname + '/app/app.html');});

  electron.session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
    details.requestHeaders['Origin'] = 'electron://graphiql-app';
    callback({ cancel: false, requestHeaders: details.requestHeaders });
  });

Did not work

  • Changing the WinINET proxy settings (also known as internet explorer proxy settings) which is the closest Windows has to a system-wide proxy settings. This is what Chrome desktop (and many other Electron apps) use.
  • Passing --proxy-server to the GraphiQL executable command line.
    • Seems like this does not work with bundled applications.
  • Extracting app.asar, adding the command line parameters for a proxy to main.js before app.on('ready'. Then repacking app.asar and running GraphiQL.
app.commandLine.appendSwitch('proxy-server', '127.0.0.1:8090');
app.commandLine.appendSwitch('ignore-certificate-errors', 'true');
app.commandLine.appendSwitch('allow-insecure-localhost', 'true');

app.on('ready', function() {

Metadata

Metadata

Assignees

Labels

new blogFuture blog ideas

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions