parsiya / parsiya.net

Source for my personal website
https://parsiya.net
11 stars 8 forks source link

Proxying electron apps #14

Open parsiya opened 4 years ago

parsiya commented 4 years ago

// 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

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() {
parsiya commented 4 years ago

Did not work, in main.js

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

  electron.session.defaultSession.setProxy({proxyRules:"http=localhost:8090;https=localhost:8090"}, function() {});
parsiya commented 4 years ago

Seems like we might need to look inside app.js and manually mess with the ClientRequest going out.

parsiya commented 3 years ago

Find a good example and try it. I think GraphiQL was not a good example. We need practical stuff. Might be hard because most consumer Electron apps honor the system proxy settings.