How connect to proxy in electron webview?


Hello for all

as I can connect through a to a free proxy server (or pay), currently in use as electron JS solution as desktop application

i am triying create a broswer

I’ve seen a library of protocol but not how to use it and how to dynamically change the protocol ( ip if not available )

PROTOCOL DOC => electron/electron/blob/master/docs/api/

I need to connect to this timely


Hi change your main.js like below code.
remove the comments in code if you wants to change that dynamically.
When ever you change proxy.pac file it will automatically reloaded.

  const {app, BrowserWindow} = require('electron');
const {session} = require('electron')

let mainWindow;

app.on('window-all-closed', function() {

app.on('ready', function() {
  mainWindow = new BrowserWindow({width: 1024, height: 768 });
  session.defaultSession.allowNTLMCredentialsForDomains('*')//to access internal sites

//var myVar = setInterval(myTimer, 60000);
//function myTimer() {
   //mainWindow.webContents.session.setProxy({pacScript:'file://' + __dirname + '/fun.pac'}, function () {return true;});

mainWindow.webContents.session.setProxy({pacScript:'file://' + __dirname + '/fun.pac'}, function () {mainWindow.loadURL('file://' + __dirname + '/browser.html');});