mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-12 18:24:22 +00:00
fix(proxy): support portable undici dispatcher typings
This commit is contained in:
@@ -9,6 +9,8 @@ import { Agent, Dispatcher, ProxyAgent, fetch as undiciFetch, setGlobalDispatche
|
|||||||
import { getProxyResolution, shouldBypassProxy } from './proxy-env';
|
import { getProxyResolution, shouldBypassProxy } from './proxy-env';
|
||||||
|
|
||||||
const FETCH_PROXY_PROTOCOLS = ['http:', 'https:'];
|
const FETCH_PROXY_PROTOCOLS = ['http:', 'https:'];
|
||||||
|
type RoutingDispatchOptions = Parameters<Dispatcher['dispatch']>[0];
|
||||||
|
type RoutingDispatchHandler = Parameters<Dispatcher['dispatch']>[1];
|
||||||
|
|
||||||
type GlobalFetchProxyConfig = {
|
type GlobalFetchProxyConfig = {
|
||||||
httpProxyUrl?: string;
|
httpProxyUrl?: string;
|
||||||
@@ -27,7 +29,7 @@ class RoutingProxyDispatcher extends Dispatcher {
|
|||||||
this.httpsProxyDispatcher = httpsProxyUrl ? new ProxyAgent(httpsProxyUrl) : null;
|
this.httpsProxyDispatcher = httpsProxyUrl ? new ProxyAgent(httpsProxyUrl) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean {
|
dispatch(options: RoutingDispatchOptions, handler: RoutingDispatchHandler): boolean {
|
||||||
return this.resolveDispatcher(options.origin).dispatch(options, handler);
|
return this.resolveDispatcher(options.origin).dispatch(options, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user