From 6e4e0a2578425b82698f93bffa2fc6763c9bff29 Mon Sep 17 00:00:00 2001 From: nsrCodes Date: Thu, 13 Nov 2025 15:11:47 +0530 Subject: [PATCH 1/2] fix: configure dns resolutiono to resolve ipv4 first for localhost --- src/main/actions/makeApiClientRequest.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/actions/makeApiClientRequest.js b/src/main/actions/makeApiClientRequest.js index 433a59bf..3fc3626c 100644 --- a/src/main/actions/makeApiClientRequest.js +++ b/src/main/actions/makeApiClientRequest.js @@ -2,6 +2,8 @@ import getProxiedAxios from "./getProxiedAxios"; import AdvancedFormData from "form-data"; const fs = require("fs"); +const dns = require("dns") +dns.setDefaultResultOrder('ipv4first'); const makeApiClientRequest = async ({ apiRequest }) => { try { From 91dbfba27c0fe773ffdeef84c0fcaac551f4d875 Mon Sep 17 00:00:00 2001 From: nsrCodes Date: Thu, 13 Nov 2025 15:51:23 +0530 Subject: [PATCH 2/2] fix: remove the earlier fix that sets a global config and create a custom http agent instead --- src/main/actions/getProxiedAxios.ts | 15 +++++++++++++++ src/main/actions/makeApiClientRequest.js | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/actions/getProxiedAxios.ts b/src/main/actions/getProxiedAxios.ts index 03fc89b4..3863c853 100644 --- a/src/main/actions/getProxiedAxios.ts +++ b/src/main/actions/getProxiedAxios.ts @@ -6,6 +6,9 @@ import { addCookiesToRequest, storeCookiesFromResponse, } from "./cookiesHelpers"; +const dns = require("dns") +import http from "http"; +import https from "https"; class PatchedHttpsProxyAgent extends HttpsProxyAgent { ca: unknown; @@ -47,8 +50,20 @@ function createAxiosInstance( }), }); } else { + /* https://github.com/requestly/requestly-desktop-app/pull/227 */ + const localhostIPv4Lookup = (hostname: any, options: any, callback: any) => { + if (hostname === 'localhost') { + dns.lookup(hostname, { ...options, family: 4 }, callback); + } else { + dns.lookup(hostname, options, callback); + } + }; + const httpAgent = new http.Agent({ lookup: localhostIPv4Lookup }); + const httpsAgent = new https.Agent({ lookup: localhostIPv4Lookup }); instance = axios.create({ proxy: false, + httpAgent, + httpsAgent, }); } diff --git a/src/main/actions/makeApiClientRequest.js b/src/main/actions/makeApiClientRequest.js index 3fc3626c..433a59bf 100644 --- a/src/main/actions/makeApiClientRequest.js +++ b/src/main/actions/makeApiClientRequest.js @@ -2,8 +2,6 @@ import getProxiedAxios from "./getProxiedAxios"; import AdvancedFormData from "form-data"; const fs = require("fs"); -const dns = require("dns") -dns.setDefaultResultOrder('ipv4first'); const makeApiClientRequest = async ({ apiRequest }) => { try {