MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getProxyFetchOptions

Function getProxyFetchOptions

source code/utils/proxy.ts:290–321  ·  view source on GitHub ↗
(opts?: { forAnthropicAPI?: boolean })

Source from the content-addressed store, hash-verified

288 * should pass `true` here.
289 */
290export function getProxyFetchOptions(opts?: { forAnthropicAPI?: boolean }): {
291 tls?: TLSConfig
292 dispatcher?: undici.Dispatcher
293 proxy?: string
294 unix?: string
295 keepalive?: false
296} {
297 const base = keepAliveDisabled ? ({ keepalive: false } as const) : {}
298
299 // ANTHROPIC_UNIX_SOCKET tunnels through the `claude ssh` auth proxy, which
300 // hardcodes the upstream to the Anthropic API. Scope to the Anthropic API
301 // client so MCP/SSE/other callers don't get their requests misrouted.
302 if (opts?.forAnthropicAPI) {
303 const unixSocket = process.env.ANTHROPIC_UNIX_SOCKET
304 if (unixSocket && typeof Bun !== 'undefined') {
305 return { ...base, unix: unixSocket }
306 }
307 }
308
309 const proxyUrl = getProxyUrl()
310
311 // If we have a proxy, use the proxy agent (which includes mTLS config)
312 if (proxyUrl) {
313 if (typeof Bun !== 'undefined') {
314 return { ...base, proxy: proxyUrl, ...getTLSFetchOptions() }
315 }
316 return { ...base, dispatcher: getProxyAgent(proxyUrl) }
317 }
318
319 // Otherwise, use TLS options directly if available
320 return { ...base, ...getTLSFetchOptions() }
321}
322
323/**
324 * Configure global HTTP agents for both axios and undici

Callers 2

client.tsFile · 0.85
getAnthropicClientFunction · 0.85

Calls 2

getProxyUrlFunction · 0.85
getTLSFetchOptionsFunction · 0.85

Tested by

no test coverage detected