Proxy support in an Electron app


#1

Hi,

I’m building a desktop app using Electron (and ReactJS). Some users of the application will be behind a proxy server thus the application needs to support this. Unfortunately I am not able to figure this thing out.

For testing purpose, I installed CCProxy on my machine. It is configured properly and is listening on port 808. When I access a webpage in a browser, the proxy software plays nicely and I get proper results back (e.g. I get prompted for user authentication if I have configured the software that way).

My intention is to simulate proxy failure (trying to get “Proxy Authentication Required” error) for my HTTP/HTTPS calls. In order to do so, intentionally I am setting my configuration incorrectly. But no matter what I do, I am not able to get this error.

I tried to do so in “setProxy” method:

remote.session.defaultSession.setProxy({
  proxyRules: 'http://localhost:9999' // Proxy server is listening on port 808
}, function (proxy) {
});

I even tried to set this as command line switch

app.commandLine.appendSwitch('proxy-server', 'localhost:9999');
app.on('ready', createWindow);

But in all cases, the application works just fine and does not throw any errors.

What am I missing here?

Any help regarding this will be highly appreciated.

Thanks