@dividenconquer/cloudflare-proxy-fetch
Version:
A robust HTTP/HTTPS proxy client implementation for Cloudflare Workers with automatic retries and proxy rotation
52 lines • 1.74 kB
TypeScript
/**
* Configuration options for the proxyFetch function.
* Extends the standard fetch RequestInit interface with proxy-specific options.
*/
export interface ProxyFetchOptions {
/**
* Proxy server configuration. Can be either:
* - A static proxy URL string (e.g., "http://username:password@proxy.example.com:8080")
* - A function that returns a proxy URL based on the current attempt number
*
* The function form is useful for proxy rotation on failures:
* ```typescript
* proxy: async (attempt) => {
* const proxies = ['proxy1', 'proxy2', 'proxy3'];
* return proxies[attempt % proxies.length];
* }
* ```
*/
proxy: string | ((attempt: number) => Promise<string> | string);
/**
* Maximum number of retry attempts when a proxy fails.
* The function will try different proxies (if provided via function)
* up to this many times before giving up.
* @default 3
*/
maxRetries?: number;
/**
* Delay in milliseconds between retry attempts.
* This helps prevent rate limiting and allows for proxy cool-down.
* @default 1000
*/
retryDelay?: number;
/**
* Maximum number of redirects to follow automatically.
* Set to 0 to disable redirect following.
* @default 10
*/
maxRedirects?: number;
/**
* Enable detailed logging of the proxy connection process.
* When true, logs each step of the connection, including:
* - Proxy selection
* - TCP connection
* - TLS upgrade
* - Request/response details
* - Chunked transfer decoding
* - Compression handling
* @default false
*/
verbose?: boolean;
}
//# sourceMappingURL=index.d.ts.map