Skip to content

Commit 9ca7b67

Browse files
authored
chore: stop api client request to be proxied (#214)
1 parent b0b3895 commit 9ca7b67

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/main/actions/getProxiedAxios.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,25 @@ let proxyConfig: ProxyConfig;
3232

3333
function createAxiosInstance(
3434
config: ProxyConfig,
35+
enableRQProxy: boolean = false,
3536
addStoredCookies: boolean = false
3637
): AxiosInstance {
37-
const instance = axios.create({
38-
proxy: false,
39-
httpAgent: new HttpsProxyAgent(`http://${config.ip}:${config.port}`),
40-
httpsAgent: new PatchedHttpsProxyAgent({
41-
host: config.ip,
42-
port: config.port,
43-
ca: readFileSync(config.rootCertPath),
44-
}),
45-
});
38+
let instance: AxiosInstance;
39+
if (enableRQProxy) {
40+
instance = axios.create({
41+
proxy: false,
42+
httpAgent: new HttpsProxyAgent(`http://${config.ip}:${config.port}`),
43+
httpsAgent: new PatchedHttpsProxyAgent({
44+
host: config.ip,
45+
port: config.port,
46+
ca: readFileSync(config.rootCertPath),
47+
}),
48+
});
49+
} else {
50+
instance = axios.create({
51+
proxy: false,
52+
});
53+
}
4654

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

6270
try {
63-
proxiedAxios = createAxiosInstance(proxyConfig);
64-
proxiedAxiosWithSessionCookies = createAxiosInstance(proxyConfig, true);
71+
proxiedAxios = createAxiosInstance(proxyConfig, false);
72+
proxiedAxiosWithSessionCookies = createAxiosInstance(proxyConfig, false, true);
6573
} catch (error) {
6674
/* Do nothing */
6775
console.error("Error creating or updating Axios instance:", error);

0 commit comments

Comments
 (0)