From be838c6c8968f164a3890538594acfd02c45e22d Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 6 Oct 2024 03:15:45 +0530 Subject: [PATCH] feat: set proxy config as per user --- server/src/routes/storage.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/server/src/routes/storage.ts b/server/src/routes/storage.ts index 02e8001c..045ee481 100644 --- a/server/src/routes/storage.ts +++ b/server/src/routes/storage.ts @@ -14,6 +14,7 @@ import { uuid } from "uuidv4"; import moment from 'moment-timezone'; import cron from 'node-cron'; import { googleSheetUpdateTasks, processGoogleSheetUpdates } from '../workflow-management/integrations/gsheet'; +import { getDecryptedProxyConfig } from './proxy'; export const router = Router(); @@ -85,15 +86,24 @@ router.delete('/runs/:fileName', async (req, res) => { */ router.put('/runs/:fileName', async (req, res) => { try { + const proxyConfig = await getDecryptedProxyConfig(req.user.id); + let proxyOptions: any = {}; + + if (proxyConfig.proxy_url) { + proxyOptions = { + server: proxyConfig.proxy_url, + ...(proxyConfig.proxy_username && proxyConfig.proxy_password && { + username: proxyConfig.proxy_username, + password: proxyConfig.proxy_password, + }), + }; + } + const id = createRemoteBrowserForRun({ browser: chromium, launchOptions: { headless: true, - proxy: { - server: '', - username: '', - password: '', - } + proxy: proxyOptions.server ? proxyOptions : undefined, } });