Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions src/main/actions/getProxiedAxios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,17 @@ let proxyConfig: ProxyConfig;

function createAxiosInstance(
config: ProxyConfig,
enableRQProxy: boolean = false,
addStoredCookies: boolean = false
): AxiosInstance {
let instance: AxiosInstance;
if (enableRQProxy) {
instance = axios.create({
proxy: false,
httpAgent: new HttpsProxyAgent(`http://${config.ip}:${config.port}`),
httpsAgent: new PatchedHttpsProxyAgent({
host: config.ip,
port: config.port,
ca: readFileSync(config.rootCertPath),
}),
});
} else {
instance = axios.create({
proxy: false,
});
}
const instance = axios.create({
proxy: false,
httpAgent: new HttpsProxyAgent(`http://${config.ip}:${config.port}`),
httpsAgent: new PatchedHttpsProxyAgent({
host: config.ip,
port: config.port,
ca: readFileSync(config.rootCertPath),
}),
});
Comment on lines +37 to +45
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify HttpsProxyAgent usage for HTTP traffic.

Line 39 uses HttpsProxyAgent for the httpAgent property, which handles HTTP requests. While HttpsProxyAgent might support HTTP, this configuration seems unusual. Typically, HTTP and HTTPS agents are different types.

Verify that HttpsProxyAgent correctly handles plain HTTP requests, or consider whether a dedicated HTTP proxy agent should be used instead.


🌐 Web query:

Does HttpsProxyAgent from https-proxy-agent support HTTP requests or only HTTPS?

💡 Result:

HttpsProxyAgent is an http.Agent that issues an HTTP CONNECT to the proxy and is intended for proxying HTTPS (and other CONNECT-using protocols like WebSocket). It’s designed for use with Node's https module — for plain HTTP requests you should use HttpProxyAgent (or proxy-agent which selects the right agent). [1][2]

Sources:
[1] https-proxy-agent README (npm).
[2] proxy-agent README / mapping (Skypack).


Replace HttpsProxyAgent with HttpProxyAgent for HTTP traffic at line 39.

HttpsProxyAgent is designed for proxying HTTPS (and other CONNECT-using protocols like WebSocket). For plain HTTP requests, use HttpProxyAgent instead.

Update line 39 from:

httpAgent: new HttpsProxyAgent(`http://${config.ip}:${config.port}`),

to:

httpAgent: new HttpProxyAgent(`http://${config.ip}:${config.port}`),

Ensure HttpProxyAgent is imported from the https-proxy-agent package.

🤖 Prompt for AI Agents
In src/main/actions/getProxiedAxios.ts around lines 37 to 45, the httpAgent is
incorrectly constructed with HttpsProxyAgent for plain HTTP traffic; replace the
HttpsProxyAgent instantiation at line 39 with HttpProxyAgent (i.e., use new
HttpProxyAgent(`http://${config.ip}:${config.port}`)) and ensure HttpProxyAgent
is imported from the https-proxy-agent package instead of HttpsProxyAgent; keep
the httpsAgent using PatchedHttpsProxyAgent and other config unchanged.


instance.interceptors.response.use(storeCookiesFromResponse);
if (addStoredCookies) {
Expand All @@ -68,8 +60,8 @@ export const createOrUpdateAxiosInstance = (
};

try {
proxiedAxios = createAxiosInstance(proxyConfig, false);
proxiedAxiosWithSessionCookies = createAxiosInstance(proxyConfig, false, true);
proxiedAxios = createAxiosInstance(proxyConfig);
proxiedAxiosWithSessionCookies = createAxiosInstance(proxyConfig, true);
} catch (error) {
/* Do nothing */
console.error("Error creating or updating Axios instance:", error);
Expand Down