proxy-from-env

Resolves the correct proxy URL for a request by reading standard *_PROXY and NO_PROXY environment variables

Library
npm
v2.1.0
73stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
35/100Needs Attention
Development Activity8
Maintenance20
Community40
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture70
Code Quality82
Innovation55
Learning Curve90

proxy-from-env is a small, focused Node.js utility that answers one question correctly: given a target URL, what proxy (if any) should handle the request, based on the standard HTTP_PROXY/HTTPS_PROXY/*_PROXY, ALL_PROXY, and NO_PROXY environment variables? It implements the de-facto conventions established by tools like curl and wget - protocol-specific proxy variables, NO_PROXY host/port matching with wildcard and dot-prefix rules, and ALL_PROXY as a fallback - so applications don’t have to reimplement this logic themselves.

The library exports a single function, getProxyForUrl, and deliberately does nothing else: it does not perform the proxying itself, leaving that to the caller (commonly paired with packages like https-proxy-agent or proxy-agent). This narrow scope has made it a foundational, widely-depended-upon piece of the Node.js HTTP tooling ecosystem.

What You Get

  • A single getProxyForUrl(url) function accepting a string, URL instance, or legacy url.parse()-shaped object
  • Protocol-aware proxy resolution - HTTPS_PROXY for https: URLs, FTP_PROXY for ftp:, WS_PROXY/WSS_PROXY for WebSocket URLs, etc.
  • NO_PROXY support with exact host matches, * to disable all proxying, dot-prefix/wildcard suffix matching, and optional port matching
  • ALL_PROXY fallback when no protocol-specific variable is set
  • Both ESM (index.js) and CommonJS (index.cjs) entry points via package exports

Common Use Cases

  • Adding standard corporate-proxy support to a custom HTTP client without reimplementing environment-variable parsing
  • Building a proxy-aware http.Agent (as https-proxy-agent/proxy-agent do) that decides per-request whether to route through a proxy
  • Respecting NO_PROXY exclusion rules so internal/intranet hosts bypass a configured proxy while external requests use it
  • Ensuring consistent proxy behavior across a Node.js tool by matching the conventions used by curl, wget, and Python’s urllib

Under The Hood

Architecture - The entire implementation lives in a single ~100-line index.js: getProxyForUrl parses the input into a URL (via a small parseUrl helper wrapping the WHATWG URL constructor), extracts protocol/hostname/port, strips brackets/ports consistently for IPv6 hosts, calls a private shouldProxy(hostname, port) to evaluate NO_PROXY rules, and finally reads the appropriate *_proxy/all_proxy environment variable via a getEnv helper that checks both lowercase and uppercase variants (lowercase wins). Tech Stack - Zero-dependency, pure JavaScript (100% JS) targeting Node.js 10+, dual-published as ESM (index.js) and CommonJS (index.cjs), linted with ESLint’s flat config (eslint.config.mjs). Code Quality - test.js is nearly 5x the size of the implementation itself (465 vs 103 lines) and is run via Node’s built-in node --test runner with coverage reporting support, indicating thorough behavioral coverage of the NO_PROXY matching rules, IPv6 handling, and case-insensitive environment variable resolution; a separate test-require.cjs specifically verifies the CommonJS entry point still works. API Design - A single exported function with no configuration object, options, or classes to learn - callers pass a URL and get back a proxy URL string or empty string, mirroring exactly what curl/wget users already expect from proxy environment variables.

Used by 7 apps in this directory

TypeScript
89%
Other

FastGPT

AI Agents · AI Development

29,387

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
70
Dependency
Built with
TypeScript89%
Updated today
TypeScript
97%
Other

Kibana

Analytics · Monitoring

21,251

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
68
Dependency
Built with
TypeScript97%
Updated today
TypeScript
92%
Other

n8n

Automation · No Code Platforms

201,152

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
66
Dependency
Built with
TypeScript92%
Updated today
TypeScript
80%
Apache 2.0

nao

AI Development · Analytics

1,570

Build and deploy an open-source analytics agent that understands your data warehouse and answers business questions in plain English.

View details
83
Repo Health
76
Technical
68
Dependency
Built with
TypeScript80%
Python19%
Updated yesterday
TypeScript
97%
Other

Outline

Knowledge Management · Collaboration

40,236

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
69
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
97%
MIT

Promptfoo

AI Development

24,362

An open-source CLI and library for evaluating and red-teaming LLM applications — replace trial-and-error prompt engineering with systematic evals, vulnerability scanning, and CI/CD integration.

View details
90
Repo Health
73
Technical
68
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,002

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
69
Dependency
Built with
TypeScript97%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search