From 3f38ad783a0f7634bf84e78b212c1405f8f8d613 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 19 Apr 2024 12:05:48 +0200 Subject: [PATCH] Add proxy support to authorizeUserInWindow (#7077) --- .../insomnia/src/main/authorizeUserInWindow.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/insomnia/src/main/authorizeUserInWindow.ts b/packages/insomnia/src/main/authorizeUserInWindow.ts index 16525e0352..8c76cb7bbc 100644 --- a/packages/insomnia/src/main/authorizeUserInWindow.ts +++ b/packages/insomnia/src/main/authorizeUserInWindow.ts @@ -34,6 +34,10 @@ export function authorizeUserInWindow({ // Fetch user setting to determine whether to validate SSL certificates during auth const { validateAuthSSL, + proxyEnabled, + httpProxy, + httpsProxy, + noProxy, } = await models.settings.get(); // Create a child window @@ -137,6 +141,17 @@ export function authorizeUserInWindow({ // Show the window to the user after it loads child.on('ready-to-show', child.show.bind(child)); + // Set proxy for browser window + if (proxyEnabled) { + await child.webContents.session.setProxy({ + proxyRules: + (httpProxy ? `http=${httpProxy};` : '') + + (httpsProxy ? `https=${httpsProxy}` : ''), + proxyBypassRules: noProxy, + }); + console.log('[oauth2] Proxy loaded'); + } + try { await child.loadURL(url); } catch (error) {