Skip to content

Commit 742d27e

Browse files
committed
fix(proxy): update environment variable check order
1 parent b5ca4c3 commit 742d27e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Node.js has no built-in support for HTTP Proxies for fetch (see [nodejs/undici#1
111111

112112
This package bundles a compact and simple proxy-supported solution for both Node.js versions without native fetch using [HTTP Agent](https://github.com/TooTallNate/proxy-agents/tree/main/packages/proxy-agent) and versions with native fetch using [Undici Proxy Agent](https://undici.nodejs.org/#/docs/api/ProxyAgent).
113113

114-
By default, `HTTP_PROXY`, `http_proxy`, `HTTPS_PROXY`, and `https_proxy` environment variables will be used for the proxy and if not any of them are set, the proxy will be disabled.
114+
By default, `https_proxy`, `http_proxy`, `HTTPS_PROXY`, and `HTTP_PROXY` environment variables will be checked and used (in order) for the proxy and if not any of them are set, the proxy will be disabled.
115115

116116
> [!NOTE]
117117
> Using export conditions, this utility adds proxy support for Node.js and for other runtimes, it will simply return native fetch.

src/proxy.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { fetch as _fetch } from "node-fetch-native";
1111
export function createProxy(opts: ProxyOptions = {}) {
1212
const uri =
1313
opts.url ||
14-
process.env.HTTPS_PROXY ||
1514
process.env.https_proxy ||
16-
process.env.HTTP_PROXY ||
17-
process.env.http_proxy;
15+
process.env.http_proxy ||
16+
process.env.HTTPS_PROXY ||
17+
process.env.HTTP_PROXY;
1818

1919
if (!uri) {
2020
return {

0 commit comments

Comments
 (0)