MCPcopy
hub / github.com/codeaashu/claude-code / createHttpsProxyAgent

Function createHttpsProxyAgent

src/utils/proxy.ts:135–161  ·  view source on GitHub ↗

* Create an HttpsProxyAgent with optional mTLS configuration * Skips local DNS resolution to let the proxy handle it

(
  proxyUrl: string,
  extra: HttpsProxyAgentOptions<string> = {},
)

Source from the content-addressed store, hash-verified

133 * Skips local DNS resolution to let the proxy handle it
134 */
135function createHttpsProxyAgent(
136 proxyUrl: string,
137 extra: HttpsProxyAgentOptions<string> = {},
138): HttpsProxyAgent<string> {
139 const mtlsConfig = getMTLSConfig()
140 const caCerts = getCACertificates()
141
142 const agentOptions: HttpsProxyAgentOptions<string> = {
143 ...(mtlsConfig && {
144 cert: mtlsConfig.cert,
145 key: mtlsConfig.key,
146 passphrase: mtlsConfig.passphrase,
147 }),
148 ...(caCerts && { ca: caCerts }),
149 }
150
151 if (isEnvTruthy(process.env.CLAUDE_CODE_PROXY_RESOLVES_HOSTS)) {
152 // Skip local DNS resolution - let the proxy resolve hostnames
153 // This is needed for environments where DNS is not configured locally
154 // and instead handled by the proxy (as in sandboxes)
155 agentOptions.lookup = (hostname, options, callback) => {
156 callback(null, hostname, getAddressFamily(options))
157 }
158 }
159
160 return new HttpsProxyAgent(proxyUrl, { ...agentOptions, ...extra })
161}
162
163/**
164 * Axios instance with its own proxy agent. Same NO_PROXY/mTLS/CA

Callers 4

createAxiosInstanceFunction · 0.85
getWebSocketProxyAgentFunction · 0.85
configureGlobalAgentsFunction · 0.85
getAWSClientProxyConfigFunction · 0.85

Calls 2

isEnvTruthyFunction · 0.85
getAddressFamilyFunction · 0.85

Tested by

no test coverage detected