Skip to content

Commit

Permalink
fix(axios): disable axios proxy when passing agent (NangoHQ#2396)
Browse files Browse the repository at this point in the history
…h kicks in with https_proxy env set

## Describe your changes
As we are using httpProxyAgent we need to disable the axios default
proxy so the httpProxyAgent is considered not the proxy with kicks in by
default when we have https_proxy env set

## Issue ticket number and link

## Checklist before requesting a review (skip if just adding/editing
APIs & templates)
- [ ] I added tests, otherwise the reason is: 
- [ ] I added observability, otherwise the reason is:
- [ ] I added analytics, otherwise the reason is:

---------

Co-authored-by: Mithlesh Singh <misingh@qualys.com>
  • Loading branch information
mithlesh135 and Mithlesh Singh authored Jun 26, 2024
1 parent 6a085c5 commit eb599c8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/utils/lib/axios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HttpProxyAgent } from 'http-proxy-agent';
import { HttpsProxyAgent } from 'https-proxy-agent';
import type { AxiosRequestConfig } from 'axios';
import axios from 'axios';
import http from 'node:http';
import type { Agent as HttpAgent } from 'node:http';
Expand All @@ -19,7 +20,13 @@ if (hasHttpsProxy) {
httpsAgent = new HttpsProxyAgent(hasHttpsProxy);
}

export const axiosInstance = axios.create({
const config: AxiosRequestConfig = {
httpAgent: httpAgent,
httpsAgent: httpsAgent
});
};

if (hasHttpProxy || hasHttpsProxy) {
config.proxy = false;
}

export const axiosInstance = axios.create(config);

0 comments on commit eb599c8

Please sign in to comment.