You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+88-54Lines changed: 88 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Contributors:
30
30
August 21, 2025 STATUS compared to [http-proxy](https://www.npmjs.com/package/http-proxy) and [httpxy](https://www.npmjs.com/package/httpxy):
31
31
32
32
- Library entirely rewritten in Typescript in a modern style, with many typings added internally and strict mode enabled.
33
-
-**HTTP/2 Support**: Full HTTP/2 support via [undici](https://github.com/nodejs/undici) with callback-based request/response lifecycle hooks.
33
+
-**HTTP/2 Support**: Full HTTP/2 support via fetch API with callback-based request/response lifecycle hooks.
34
34
- All dependent packages updated to latest versions, addressing all security vulnerabilities according to `pnpm audit`.
35
35
- Code rewritten to not use deprecated/insecure API's, e.g., using `URL` instead of `parse`.
36
36
- Fixed socket leaks in the Websocket proxy code, going beyond [http-proxy-node16](https://www.npmjs.com/package/http-proxy-node16) to also instrument and logging socket counts. Also fixed an issue with uncatchable errors when using websockets.
@@ -90,7 +90,7 @@ This is the original user's guide, but with various updates.
90
90
-[Setup a stand-alone proxy server with latency](#setup-a-stand-alone-proxy-server-with-latency)
91
91
-[Using HTTPS](#using-https)
92
92
-[Proxying WebSockets](#proxying-websockets)
93
-
-[HTTP/2 Support with Undici](#http2-support-with-undici)
93
+
-[HTTP/2 Support with Fetch](#http2-support-with-fetch)
> **⚠️ Experimental Feature**: The undici code path for HTTP/2 support is currently experimental. While it provides full HTTP/2 functionality and has comprehensive test coverage, the API and behavior may change in future versions. Use with caution in production environments.
445
+
> **⚠️ Experimental Feature**: The fetch code path for HTTP/2 support is currently experimental. While it provides HTTP/2 functionality and has comprehensive test coverage, the API and behavior may change in future versions. Use with caution in production environments.
446
+
447
+
http-proxy-3 supports HTTP/2 through the native fetch API. When fetch is enabled, the proxy can communicate with HTTP/2 servers. The fetch code path is runtime-agnostic and works across different JavaScript runtimes (Node.js, Deno, Bun, etc.). However, this means HTTP/2 support depends on the runtime. Deno enables HTTP/2 by default, Bun currently does not and Node.js requires to set a different dispatcher. See next section for Node.js details.
445
448
446
-
http-proxy-3 supports HTTP/2 through [undici](https://github.com/nodejs/undici), a modern HTTP client. When undici is enabled, the proxy can communicate with HTTP/2 servers and provides enhanced performance and features.
- **ca**: Optionally override the trusted CA certificates. This is passed to https.request.
635
664
636
-
- **undici**: Enable undici for HTTP/2 support. Set to `true` for defaults, or provide custom configuration:
637
-
- `agentOptions`: Configuration for undici Agent (see [undici Agent.Options](https://github.com/nodejs/undici/blob/main/docs/api/Agent.md))
638
-
- `requestOptions`: Configuration for undici requests (see [undici Dispatcher.RequestOptions](https://github.com/nodejs/undici/blob/main/docs/api/Dispatcher.md#dispatcherrequestoptions))
639
-
- `onBeforeRequest`: Async callback called before making the undici request
640
-
- `onAfterResponse`: Async callback called after receiving the undici response
665
+
- **fetch**: Enable fetch API for HTTP/2 support. Set to `true` for defaults, or provide custom configuration:
666
+
- `dispatcher`: Custom fetch dispatcher (e.g., undici Agent with `allowH2: true` for HTTP/2)
- ¹ `secure` is not directly supported in the fetch path. Instead, use `fetch.dispatcher` with `{connect: {rejectUnauthorized: false}}` to disable SSL certificate verification (e.g., for self-signed certificates).
687
720
688
721
**Code Path Selection:**
689
722
- **Native Path**: Used by default, supports HTTP/1.1 and WebSockets
690
-
- **Undici Path**: Activated when `undici` option is provided, supports HTTP/2
723
+
- **Fetch Path**: Activated when `fetch` option is provided, supports HTTP/2 (with appropriate dispatcher)
691
724
692
725
**Event Compatibility:**
693
726
- **Native Path**: Emits traditional events (`proxyReq`, `proxyRes`, `proxyReqWs`)
@@ -705,7 +738,7 @@ The following table shows which configuration options are compatible with differ
705
738
- `close`: This event is emitted once the proxy websocket was closed.
706
739
- (DEPRECATED) `proxySocket`: Deprecated in favor of `open`.
707
740
708
-
**Note**: When using the undici code path (HTTP/2), the `proxyReq` and `proxyRes` events are **not** emitted. Instead, use the `onBeforeRequest` and `onAfterResponse` callback functions in the `undici` configuration.
741
+
**Note**: When using the fetch code path (HTTP/2), the `proxyReq` and `proxyRes` events are **not** emitted. Instead, use the `onBeforeRequest` and `onAfterResponse` callback functions in the `fetch` configuration.
0 commit comments