{"_id":"proxy-from-env","_rev":"4252407","name":"proxy-from-env","description":"Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"rob-w","email":"rob@robwu.nl"}],"time":{"modified":"2026-04-02T02:26:58.000Z","created":"2016-02-18T21:06:51.722Z","2.1.0":"2026-03-14T18:32:47.942Z","2.0.0":"2026-02-09T03:20:22.842Z","1.1.0":"2020-03-04T03:35:19.815Z","1.0.0":"2017-02-24T10:26:18.024Z","0.1.1":"2016-10-17T20:43:13.490Z","0.1.0":"2016-02-19T12:18:09.827Z","0.0.1":"2016-02-18T21:06:51.722Z"},"users":{},"author":{"name":"Rob Wu","email":"rob@robwu.nl","url":"https://robwu.nl/"},"repository":{"type":"git","url":"git+https://github.com/Rob--W/proxy-from-env.git"},"versions":{"2.1.0":{"name":"proxy-from-env","version":"2.1.0","description":"Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.","main":"index.cjs","exports":{"import":"./index.js","require":"./index.cjs"},"scripts":{"lint":"eslint *.js *.mjs *.cjs","test":"node --test ./test.js","test-require":"node ./test-require.cjs","test-coverage":"node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info ./test.js","test-coverage-as-html":"npm run test-coverage && genhtml lcov.info -o coverage/"},"repository":{"type":"git","url":"git+https://github.com/Rob--W/proxy-from-env.git"},"keywords":["proxy","http_proxy","https_proxy","no_proxy","environment"],"author":{"name":"Rob Wu","email":"rob@robwu.nl","url":"https://robwu.nl/"},"license":"MIT","bugs":{"url":"https://github.com/Rob--W/proxy-from-env/issues"},"homepage":"https://github.com/Rob--W/proxy-from-env#readme","devDependencies":{"eslint":"^9.39.2"},"type":"module","engines":{"node":">=10"},"sideEffects":false,"gitHead":"570ce3a4279d83af3ff13e7600a347d01c453394","_id":"proxy-from-env@2.1.0","_nodeVersion":"25.7.0","_npmVersion":"11.10.1","dist":{"shasum":"a7487568adad577cfaaa7e88c49cab3ab3081aba","size":5358,"noattachment":false,"key":"/proxy-from-env/-/proxy-from-env-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/proxy-from-env/download/proxy-from-env-2.1.0.tgz"},"_npmUser":{"name":"rob-w","email":"rob@robwu.nl"},"directories":{},"maintainers":[{"name":"rob-w","email":"rob@robwu.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/proxy-from-env_2.1.0_1773513167766_0.3427019055310345"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-03-14T18:32:47.942Z","publish_time":1773513167942,"_source_registry_name":"default","_cnpm_publish_time":1773513167942},"2.0.0":{"name":"proxy-from-env","version":"2.0.0","description":"Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.","main":"index.js","exports":"./index.js","scripts":{"lint":"eslint *.js *.mjs","test":"node --test ./test.js","test-coverage":"node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info ./test.js","test-coverage-as-html":"npm run test-coverage && genhtml lcov.info -o coverage/"},"repository":{"type":"git","url":"git+https://github.com/Rob--W/proxy-from-env.git"},"keywords":["proxy","http_proxy","https_proxy","no_proxy","environment"],"author":{"name":"Rob Wu","email":"rob@robwu.nl","url":"https://robwu.nl/"},"license":"MIT","bugs":{"url":"https://github.com/Rob--W/proxy-from-env/issues"},"homepage":"https://github.com/Rob--W/proxy-from-env#readme","devDependencies":{"eslint":"^9.39.2"},"type":"module","sideEffects":false,"gitHead":"f4d1be891d62de174d46bb1fd01ba58e376d739c","_id":"proxy-from-env@2.0.0","_nodeVersion":"25.6.0","_npmVersion":"11.8.0","dist":{"shasum":"3f9786a14a3c1f73a5a9e10f70fd0cb81e27eb4d","size":9172,"noattachment":false,"key":"/proxy-from-env/-/proxy-from-env-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/proxy-from-env/download/proxy-from-env-2.0.0.tgz"},"_npmUser":{"name":"rob-w","email":"rob@robwu.nl"},"directories":{},"maintainers":[{"name":"rob-w","email":"rob@robwu.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/proxy-from-env_2.0.0_1770607222644_0.7787215475205844"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-09T03:20:22.842Z","publish_time":1770607222842,"_source_registry_name":"default","_cnpm_publish_time":1770607222842},"1.1.0":{"name":"proxy-from-env","version":"1.1.0","description":"Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.","main":"index.js","scripts":{"lint":"eslint *.js","test":"mocha ./test.js --reporter spec","test-coverage":"istanbul cover ./node_modules/.bin/_mocha -- --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Rob--W/proxy-from-env.git"},"keywords":["proxy","http_proxy","https_proxy","no_proxy","environment"],"author":{"name":"Rob Wu","email":"rob@robwu.nl","url":"https://robwu.nl/"},"license":"MIT","bugs":{"url":"https://github.com/Rob--W/proxy-from-env/issues"},"homepage":"https://github.com/Rob--W/proxy-from-env#readme","devDependencies":{"coveralls":"^3.0.9","eslint":"^6.8.0","istanbul":"^0.4.5","mocha":"^7.1.0"},"gitHead":"96d01f8fcfdccfb776735751132930bbf79c4a3a","_id":"proxy-from-env@1.1.0","_nodeVersion":"13.7.0","_npmVersion":"6.13.6","_npmUser":{"name":"rob-w","email":"rob@robwu.nl"},"maintainers":[{"name":"rob-w","email":"rob@robwu.nl"}],"dist":{"shasum":"e102f16ca355424865755d2c9e8ea4f24d58c3e2","size":7772,"noattachment":false,"key":"/proxy-from-env/-/proxy-from-env-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/proxy-from-env/download/proxy-from-env-1.1.0.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/proxy-from-env_1.1.0_1583292919676_0.18466952575605178"},"_hasShrinkwrap":false,"publish_time":1583292919815,"_cnpm_publish_time":1583292919815},"1.0.0":{"name":"proxy-from-env","version":"1.0.0","description":"Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.","main":"index.js","scripts":{"lint":"jscs *.js && jshint *.js","test":"mocha ./test.js --reporter spec","test-coverage":"istanbul cover ./node_modules/.bin/_mocha -- --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Rob--W/proxy-from-env.git"},"keywords":["proxy","http_proxy","https_proxy","no_proxy","environment"],"author":{"name":"Rob Wu","email":"rob@robwu.nl","url":"https://robwu.nl/"},"license":"MIT","bugs":{"url":"https://github.com/Rob--W/proxy-from-env/issues"},"homepage":"https://github.com/Rob--W/proxy-from-env#readme","devDependencies":{"coveralls":"^2.11.6","istanbul":"^0.4.2","jscs":"^2.10.1","jshint":"^2.9.1","mocha":"^2.4.5"},"gitHead":"bdf563343ff76e88402e1ab0b5040515b71502b5","_id":"proxy-from-env@1.0.0","_shasum":"33c50398f70ea7eb96d21f7b817630a55791c7ee","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"rob-w","email":"rob@robwu.nl"},"maintainers":[{"name":"rob-w","email":"rob@robwu.nl"}],"dist":{"shasum":"33c50398f70ea7eb96d21f7b817630a55791c7ee","size":6718,"noattachment":false,"key":"/proxy-from-env/-/proxy-from-env-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/proxy-from-env/download/proxy-from-env-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/proxy-from-env-1.0.0.tgz_1487931977410_0.9466661661863327"},"directories":{},"publish_time":1487931978024,"_cnpm_publish_time":1487931978024,"_hasShrinkwrap":false},"0.1.1":{"name":"proxy-from-env","version":"0.1.1","description":"Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.","main":"index.js","scripts":{"lint":"jscs *.js && jshint *.js","test":"mocha ./test.js --reporter spec","test-coverage":"istanbul cover ./node_modules/.bin/_mocha -- --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Rob--W/proxy-from-env.git"},"keywords":["proxy","http_proxy","https_proxy","no_proxy","environment"],"author":{"name":"Rob Wu","email":"rob@robwu.nl","url":"https://robwu.nl/"},"license":"MIT","bugs":{"url":"https://github.com/Rob--W/proxy-from-env/issues"},"homepage":"https://github.com/Rob--W/proxy-from-env#readme","devDependencies":{"coveralls":"^2.11.6","istanbul":"^0.4.2","jscs":"^2.10.1","jshint":"^2.9.1","mocha":"^2.4.5"},"gitHead":"6266d30c373153b55ed46a97aff81250f0433e68","_id":"proxy-from-env@0.1.1","_shasum":"c5f529b41d2a23f1f81f7ee258974fb80885a6e7","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"rob-w","email":"rob@robwu.nl"},"maintainers":[{"name":"rob-w","email":"rob@robwu.nl"}],"dist":{"shasum":"c5f529b41d2a23f1f81f7ee258974fb80885a6e7","size":6715,"noattachment":false,"key":"/proxy-from-env/-/proxy-from-env-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/proxy-from-env/download/proxy-from-env-0.1.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/proxy-from-env-0.1.1.tgz_1476736991549_0.034898495534434915"},"directories":{},"publish_time":1476736993490,"_cnpm_publish_time":1476736993490,"_hasShrinkwrap":false},"0.1.0":{"name":"proxy-from-env","version":"0.1.0","description":"Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.","main":"index.js","scripts":{"lint":"jscs index.js && jshint index.js ;:","test":"mocha ./test.js --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Rob--W/proxy-from-env.git"},"keywords":["proxy","http_proxy","https_proxy","no_proxy","environment"],"author":{"name":"Rob Wu","email":"rob@robwu.nl","url":"https://robwu.nl/"},"license":"MIT","bugs":{"url":"https://github.com/Rob--W/proxy-from-env/issues"},"homepage":"https://github.com/Rob--W/proxy-from-env#readme","devDependencies":{"mocha":"^2.4.5"},"gitHead":"4096700204437c8926756fcda4d86610eed18643","_id":"proxy-from-env@0.1.0","_shasum":"3ade4afe2debe279de8421afef60fdb179ec410f","_from":".","_npmVersion":"2.9.0","_nodeVersion":"5.6.0","_npmUser":{"name":"rob-w","email":"rob@robwu.nl"},"maintainers":[{"name":"rob-w","email":"rob@robwu.nl"}],"dist":{"shasum":"3ade4afe2debe279de8421afef60fdb179ec410f","size":5356,"noattachment":false,"key":"/proxy-from-env/-/proxy-from-env-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/proxy-from-env/download/proxy-from-env-0.1.0.tgz"},"_npmOperationalInternal":{"host":"packages-9-west.internal.npmjs.com","tmp":"tmp/proxy-from-env-0.1.0.tgz_1455884285734_0.5764795215800405"},"directories":{},"publish_time":1455884289827,"_cnpm_publish_time":1455884289827,"_hasShrinkwrap":false},"0.0.1":{"name":"proxy-from-env","version":"0.0.1","description":"Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.","main":"index.js","scripts":{"lint":"jscs index.js && jshint index.js ;:","test":"mocha ./test.js --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/Rob--W/proxy-from-env.git"},"keywords":["proxy","http_proxy","https_proxy","no_proxy","environment"],"author":{"name":"Rob Wu","email":"rob@robwu.nl","url":"https://robwu.nl/"},"license":"MIT","bugs":{"url":"https://github.com/Rob--W/proxy-from-env/issues"},"homepage":"https://github.com/Rob--W/proxy-from-env#readme","devDependencies":{"mocha":"^2.4.5"},"gitHead":"46bf283b345b5526ed38d5cd29eadb66879ca690","_id":"proxy-from-env@0.0.1","_shasum":"b27c4946e9e6d5dbadb7598a6435d3014c4cfd49","_from":".","_npmVersion":"2.9.0","_nodeVersion":"5.6.0","_npmUser":{"name":"rob-w","email":"rob@robwu.nl"},"maintainers":[{"name":"rob-w","email":"rob@robwu.nl"}],"dist":{"shasum":"b27c4946e9e6d5dbadb7598a6435d3014c4cfd49","size":5164,"noattachment":false,"key":"/proxy-from-env/-/proxy-from-env-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/proxy-from-env/download/proxy-from-env-0.0.1.tgz"},"_npmOperationalInternal":{"host":"packages-6-west.internal.npmjs.com","tmp":"tmp/proxy-from-env-0.0.1.tgz_1455829607680_0.3209165702573955"},"directories":{},"publish_time":1455829611722,"_cnpm_publish_time":1455829611722,"_hasShrinkwrap":false}},"readme":"# proxy-from-env\n\n![Build Status](https://github.com/Rob--W/proxy-from-env/actions/workflows/run-tests.yaml/badge.svg?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/Rob--W/proxy-from-env/badge.svg?branch=master)](https://coveralls.io/github/Rob--W/proxy-from-env?branch=master)\n\n`proxy-from-env` is a Node.js package that exports a function (`getProxyForUrl`)\nthat takes an input URL (a string, an instance of\n[`URL`](https://nodejs.org/docs/latest/api/url.html#the-whatwg-url-api),\nor [`url.parse`](https://nodejs.org/docs/latest/api/url.html#url_url_parsing)'s\nreturn value) and returns the desired proxy URL (also a string) based on\nstandard proxy environment variables. If no proxy is set, an empty string is\nreturned.\n\nIf your application makes important (security) decisions based on the URL, be\nconsistent in the mechanism to parse and validate URLs, as differences in URL\nparsing behavior can affect the outcome of proxy resolution.\nStrings are parsed with the standard `URL` API, as of `proxy-from-env@2.0.0`.\nOlder versions relied on the (now deprecated) `url.parse` method instead.\n\nInvalid values in environment variables are not handled by the library\n([#41](https://github.com/Rob--W/proxy-from-env/issues/41)).\n\nIt is your responsibility to actually proxy the request using the given URL.\n\nInstallation:\n\n```sh\nnpm install proxy-from-env\n```\n\n## Example\nThis example shows how the data for a URL can be fetched via the\n[`http` module](https://nodejs.org/api/http.html), in a proxy-aware way.\n\nwarning: this simple example works for http requests only. To support https,\nyou must establish a proxy tunnel via the\n[http `connect` method](https://developer.mozilla.org/en-us/docs/web/http/reference/methods/connect).\n\n```javascript\nimport http from 'node:test';\nimport { getProxyForUrl } from 'proxy-from-env';\n// ^ or: var getProxyForUrl = require('proxy-from-env').getProxyForUrl;\n\nvar some_url = 'http://example.com/something';\n\n// // Example, if there is a proxy server at 10.0.0.1:1234, then setting the\n// // http_proxy environment variable causes the request to go through a proxy.\n// process.env.http_proxy = 'http://10.0.0.1:1234';\n// \n// // But if the host to be proxied is listed in NO_PROXY, then the request is\n// // not proxied (but a direct request is made).\n// process.env.no_proxy = 'example.com';\n\nvar proxy_url = getProxyForUrl(some_url);  // <-- Our magic.\nif (proxy_url) {\n  // Should be proxied through proxy_url.\n  var parsed_some_url = new URL(some_url);\n  var parsed_proxy_url = new URL(proxy_url);\n  // A HTTP proxy is quite simple. It is similar to a normal request, except the\n  // path is an absolute URL, and the proxied URL's host is put in the header\n  // instead of the server's actual host.\n  httpOptions = {\n    protocol: parsed_proxy_url.protocol,\n    hostname: parsed_proxy_url.hostname,\n    port: parsed_proxy_url.port,\n    path: parsed_some_url.href,\n    headers: {\n      Host: parsed_some_url.host,  // = host name + optional port.\n    },\n  };\n} else {\n  // Direct request.\n  httpOptions = some_url;\n}\nhttp.get(httpOptions, function(res) {\n  var responses = [];\n  res.on('data', function(chunk) { responses.push(chunk); });\n  res.on('end', function() { console.log(responses.join(''));  });\n});\n```\n\n### Full proxy support\nThe simple example above works for http requests only. To support https, you\nmust establish a proxy tunnel via the\n[http `connect` method](https://developer.mozilla.org/en-us/docs/web/http/reference/methods/connect).\n\nAn example of that is shown in the\n[`https-proxy-agent` npm package](https://www.npmjs.com/package/https-proxy-agent).\nThe [`proxy-agent` npm package](https://www.npmjs.com/package/proxy-agent)\ncombines `https-proxy-agent` and `proxy-from-env` to offer a `http.Agent` that\nsupports proxies from environment variables.\n\n### Built-in proxy support\nNode.js is working on built-in support for proxy environment variables,\ncurrently behind `NODE_USE_ENV_PROXY=1` or `--use-env-proxy`. For details, see:\n\n- https://github.com/nodejs/node/issues/57872\n- https://nodejs.org/api/http.html#built-in-proxy-support\n\n\n## Environment variables\nThe environment variables can be specified in all lowercase or all uppercase,\nwith lowercase taking precedence over the uppercase variant. A variable that is\nnot set has the same meaning as a variable that is set but has no value.\n\n### NO\\_PROXY\n\n`NO_PROXY` is a list of host names (optionally with a port). If the input URL\nmatches any of the entries in `NO_PROXY`, then the input URL should be fetched\nby a direct request (i.e. without a proxy).\n\nMatching follows the following rules:\n\n- `NO_PROXY=*` disables all proxies.\n- Space and commas may be used to separate the entries in the `NO_PROXY` list.\n- If `NO_PROXY` does not contain any entries, then proxies are never disabled.\n- If a port is added after the host name, then the ports must match. If the URL\n  does not have an explicit port name, the protocol's default port is used.\n- Generally, the proxy is only disabled if the host name is an exact match for\n  an entry in the `NO_PROXY` list. The only exceptions are entries that start\n  with a dot or with a wildcard; then the proxy is disabled if the host name\n  ends with the entry.\n\nSee `test.js` for examples of what should match and what does not.\n\n### \\*\\_PROXY\n\nThe environment variable used for the proxy depends on the protocol of the URL.\nFor example, `https://example.com` uses the \"https\" protocol, and therefore the\nproxy to be used is `HTTPS_PROXY` (_NOT_ `HTTP_PROXY`, which is _only_ used for\nhttp:-URLs).\n\nThe library is not limited to http(s), other schemes such as\n`FTP_PROXY` (ftp:),\n`WSS_PROXY` (wss:),\n`WS_PROXY` (ws:)\nare also supported.\n\nIf present, `ALL_PROXY` is used as fallback if there is no other match.\n\n\n## External resources\nThe exact way of parsing the environment variables is not codified in any\nstandard. This library is designed to be compatible with formats as expected by\nexisting software.\nThe following resources were used to determine the desired behavior:\n\n- cURL:\n  https://curl.haxx.se/docs/manpage.html#ENVIRONMENT  \n  https://github.com/curl/curl/blob/4af40b3646d3b09f68e419f7ca866ff395d1f897/lib/url.c#L4446-L4514  \n  https://github.com/curl/curl/blob/4af40b3646d3b09f68e419f7ca866ff395d1f897/lib/url.c#L4608-L4638  \n\n- wget: \n  https://www.gnu.org/software/wget/manual/wget.html#Proxies  \n  http://git.savannah.gnu.org/cgit/wget.git/tree/src/init.c?id=636a5f9a1c508aa39e35a3a8e9e54520a284d93d#n383  \n  http://git.savannah.gnu.org/cgit/wget.git/tree/src/retr.c?id=93c1517c4071c4288ba5a4b038e7634e4c6b5482#n1278  \n\n- W3:\n  https://www.w3.org/Daemon/User/Proxies/ProxyClients.html  \n\n- Python's urllib:\n  https://github.com/python/cpython/blob/936135bb97fe04223aa30ca6e98eac8f3ed6b349/Lib/urllib/request.py#L755-L782  \n  https://github.com/python/cpython/blob/936135bb97fe04223aa30ca6e98eac8f3ed6b349/Lib/urllib/request.py#L2444-L2479\n","_attachments":{},"homepage":"https://github.com/Rob--W/proxy-from-env#readme","bugs":{"url":"https://github.com/Rob--W/proxy-from-env/issues"},"license":"MIT"}