nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.34k stars 3.88k forks source link

Domain specific Proxy support #5530

Open myfrndjk opened 7 years ago

myfrndjk commented 7 years ago

Hi,

I am developing an app which requires to route the traffic of each domain via respective proxy. Do we have option to use PAC url for proxy support .If not how do we set up proxy for different domains like site : abc.com proxy : 12345:80 site : xyz.com proxy : 9999999:8880

Already if we have option to set up proxy can some one share a sample code

Thanks

ghostoy commented 7 years ago

FYI @fujunwei

fujunwei commented 7 years ago

You can use the chrome.proxy API to manage Chrome's proxy settings. The following code sets a custom PAC script.

var config = { mode: "pac_script", pacScript: { data: "function FindProxyForURL(url, host) {\n" + " if (host == 'foobar.com')\n" + " return 'PROXY blackhole:80';\n" + " return 'DIRECT';\n" + "}" } }; chrome.proxy.settings.set( {value: config, scope: 'regular'}, function() {});

ghostoy commented 7 years ago

@fujunwei Looks like chrome.proxy API was broken. Would you like to look at into it?

myfrndjk commented 7 years ago

@ghostoy : Thanks for heads up i will try once it is fixed

myfrndjk commented 7 years ago

@fujunwei : Thanks for your suggestion.Since i am new to nw.js I am not sure where to add these lines.Do I need to add these lines in package.json ?