Skip to content

Commit

Permalink
fix(proxy): update environment variable check order
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 24, 2023
1 parent b5ca4c3 commit 742d27e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Node.js has no built-in support for HTTP Proxies for fetch (see [nodejs/undici#1

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).

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.
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.

> [!NOTE]
> Using export conditions, this utility adds proxy support for Node.js and for other runtimes, it will simply return native fetch.
Expand Down
6 changes: 3 additions & 3 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { fetch as _fetch } from "node-fetch-native";
export function createProxy(opts: ProxyOptions = {}) {
const uri =
opts.url ||
process.env.HTTPS_PROXY ||
process.env.https_proxy ||
process.env.HTTP_PROXY ||
process.env.http_proxy;
process.env.http_proxy ||
process.env.HTTPS_PROXY ||
process.env.HTTP_PROXY;

if (!uri) {
return {
Expand Down

0 comments on commit 742d27e

Please sign in to comment.