@@ -534,30 +534,6 @@ const proxy = createProxyServer({
534534}).listen (8443 );
535535```
536536
537- ##### Using Custom Fetch Implementation
538-
539- ``` js
540- import { createProxyServer } from " http-proxy-3" ;
541- import { fetch as undiciFetch , Agent } from " undici" ;
542-
543- // Wrap undici's fetch with custom configuration
544- function customFetch (url , opts ) {
545- opts = opts || {};
546- opts .dispatcher = new Agent ({ allowH2: true });
547- return undiciFetch (url, opts);
548- }
549-
550- const proxy = createProxyServer ({
551- target: " https://api.example.com" ,
552- fetch: {
553- // Pass your custom fetch implementation
554- customFetch,
555- onBeforeRequest: async (requestOptions , req , res , options ) => {
556- requestOptions .headers [' X-Custom' ] = ' value' ;
557- }
558- }
559- });
560- ```
561537
562538** Important Notes:**
563539- When ` fetch ` option is provided, the proxy uses the fetch API instead of Node.js native ` http ` /` https ` modules
@@ -668,7 +644,6 @@ const proxy = createProxyServer({
668644 - `requestOptions`: Additional fetch request options
669645 - `onBeforeRequest`: Async callback called before making the fetch request
670646 - `onAfterResponse`: Async callback called after receiving the fetch response
671- - `customFetch`: Custom fetch implementation to use instead of the global fetch
672647
673648**NOTE:**
674649`options.ws` and `options.ssl` are optional.
0 commit comments