diff --git a/app/src/components/mainWindow/mainWindow.js b/app/src/components/mainWindow/mainWindow.js index d3b53af..dcff241 100644 --- a/app/src/components/mainWindow/mainWindow.js +++ b/app/src/components/mainWindow/mainWindow.js @@ -75,6 +75,15 @@ function clearCache(browserWindow, targetUrl = null) { }); } +function setProxyRules(browserWindow, proxyRules) { + browserWindow.webContents.session.setProxy( + { + proxyRules, + }, + () => {}, + ); +} + /** * * @param {{}} inpOptions AppArgs from nativefier.json @@ -284,6 +293,11 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) { if (options.userAgent) { window.webContents.setUserAgent(options.userAgent); } + + if (options.proxyRules) { + setProxyRules(window, options.proxyRules); + } + maybeInjectCss(window); sendParamsOnDidFinishLoad(window); window.webContents.on('new-window', onNewWindow); @@ -318,6 +332,10 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) { mainWindow.webContents.setUserAgent(options.userAgent); } + if (options.proxyRules) { + setProxyRules(mainWindow, options.proxyRules); + } + maybeInjectCss(mainWindow); sendParamsOnDidFinishLoad(mainWindow); diff --git a/docs/api.md b/docs/api.md index c4273f7..d5ef9ea 100644 --- a/docs/api.md +++ b/docs/api.md @@ -43,6 +43,7 @@ - [[enable-es3-apis]](#enable-es3-apis) - [[insecure]](#insecure) - [[internal-urls]](#internal-urls) + - [[proxy-rules]](#proxy-rules) - [[flash]](#flash) - [[flash-path]](#flash-path) - [[disk-cache-size]](#disk-cache-size) @@ -378,6 +379,21 @@ Or, if you want to allow all domains for example for external auths, nativefier https://google.com --internal-urls ".*?" ``` + +#### [proxy-rules] + +``` +--proxy-rules +``` + +Proxy rules. See [proxyRules](https://electronjs.org/docs/api/session?q=proxy#sessetproxyconfig-callback) for more details. + +Example: + +```bash +nativefier https://google.com --proxy-rules http://127.0.0.1:1080 +``` + #### [flash] ``` diff --git a/src/build/buildApp.js b/src/build/buildApp.js index 1391411..a92317c 100644 --- a/src/build/buildApp.js +++ b/src/build/buildApp.js @@ -42,6 +42,7 @@ function selectAppArgs(options) { disableDevTools: options.disableDevTools, zoom: options.zoom, internalUrls: options.internalUrls, + proxyRules: options.proxyRules, crashReporter: options.crashReporter, singleInstance: options.singleInstance, clearCache: options.clearCache, diff --git a/src/cli.js b/src/cli.js index 00324f6..f2355d3 100755 --- a/src/cli.js +++ b/src/cli.js @@ -200,6 +200,10 @@ if (require.main === module) { '--internal-urls ', 'regular expression of URLs to consider "internal"; all other URLs will be opened in an external browser. (default: URLs on same second-level domain as app)', ) + .option( + '--proxy-rules ', + 'proxy rules. See https://electronjs.org/docs/api/session?q=proxy#sessetproxyconfig-callback', + ) .option( '--crash-reporter ', 'remote server URL to send crash reports', diff --git a/src/options/optionsMain.js b/src/options/optionsMain.js index 72c1de3..5cf883d 100644 --- a/src/options/optionsMain.js +++ b/src/options/optionsMain.js @@ -58,6 +58,7 @@ export default function(inpOptions) { tmpdir: false, zoom: inpOptions.zoom || 1.0, internalUrls: inpOptions.internalUrls || null, + proxyRules: inpOptions.proxyRules || null, singleInstance: inpOptions.singleInstance || false, clearCache: inpOptions.clearCache || false, appVersion: inpOptions.appVersion,