From 2803e44eb1bd2115688171f135765bfb4921f685 Mon Sep 17 00:00:00 2001 From: Aneesh Relan Date: Thu, 30 Sep 2021 14:20:11 +0530 Subject: [PATCH] fix: remove handling of NO_PROXY (#3) NO_PROXY can still be used to bypass proxies for a comma separated list of hosts but not passed to the tunnel agent --- commitlint.config.js | 1 + src/index.ts | 3 +-- tests/{proxios.test.ts => praxios.test.ts} | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) rename tests/{proxios.test.ts => praxios.test.ts} (80%) diff --git a/commitlint.config.js b/commitlint.config.js index 01f547d..05122d5 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -2,5 +2,6 @@ module.exports = { extends: ["@commitlint/config-conventional"], rules: { "body-max-line-length": [0, "always"], + "footer-max-line-length": [0, "always"], }, }; diff --git a/src/index.ts b/src/index.ts index af047af..d88285e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; @@ -22,7 +22,6 @@ if (isProxyDefined()) { proxy: { host: PROXY_HOST!, port: Number(PROXY_PORT!), - localAddress: NO_PROXY, proxyAuth: getProxyAuth(), }, }); diff --git a/tests/proxios.test.ts b/tests/praxios.test.ts similarity index 80% rename from tests/proxios.test.ts rename to tests/praxios.test.ts index 38dfd70..3fdcf32 100644 --- a/tests/proxios.test.ts +++ b/tests/praxios.test.ts @@ -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(); + }); });