Skip to content

Commit

Permalink
fix: remove handling of NO_PROXY (#3)
Browse files Browse the repository at this point in the history
NO_PROXY can still be used to bypass proxies for a comma separated list of hosts but not passed to the tunnel agent
  • Loading branch information
aneeshrelan committed Sep 30, 2021
1 parent bbfb4b7 commit 2803e44
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"body-max-line-length": [0, "always"],
"footer-max-line-length": [0, "always"],
},
};
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";
import * as tunnel from "tunnel";

const { PROXY_HOST, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWORD, NO_PROXY } = process.env;
const { PROXY_HOST, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWORD } = process.env;

const isProxyDefined = (): boolean => {
return PROXY_HOST !== undefined && PROXY_PORT !== undefined;
Expand All @@ -22,7 +22,6 @@ if (isProxyDefined()) {
proxy: {
host: PROXY_HOST!,
port: Number(PROXY_PORT!),
localAddress: NO_PROXY,
proxyAuth: getProxyAuth(),
},
});
Expand Down
12 changes: 12 additions & 0 deletions tests/proxios.test.ts → tests/praxios.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,16 @@ describe("praxios", () => {
expect(praxios).toHaveProperty("baseAxios");
expect(praxios).toHaveProperty("tunnel");
});

test("NO_PROXY env var is not considered in the tunnel agent", async () => {
process.env.PROXY_HOST = "dummy";
process.env.PROXY_PORT = "3128";
process.env.PROXY_USERNAME = "foo";
process.env.PROXY_PASSWORD = "bar";
process.env.NO_PROXY = "host1,host2";

const praxios = (await import("../src/index")).default;

expect(praxios.defaults.httpsAgent.proxyOptions.localAddress).toBeUndefined();
});
});

0 comments on commit 2803e44

Please sign in to comment.