(input: string | URL, init?: RequestInit)
| 102 | * Falls through to the global fetch when no proxy applies. |
| 103 | */ |
| 104 | export async function proxyFetch(input: string | URL, init?: RequestInit): Promise<Response> { |
| 105 | const url = typeof input === 'string' ? input : input.toString(); |
| 106 | const dispatcher = getDispatcherForUrl(url); |
| 107 | if (!dispatcher) return fetch(input, init); |
| 108 | // Node's fetch accepts a `dispatcher` option via the undici-bridge but TypeScript's |
| 109 | // built-in lib.dom RequestInit doesn't know about it. Cast through any. |
| 110 | return fetch(input, { ...(init ?? {}), dispatcher } as any); |
| 111 | } |
| 112 | |
| 113 | /** Test/debug helper: force-reset the cached config + dispatchers. */ |
| 114 | export function _resetProxyCacheForTesting(): void { |
no test coverage detected