diff --git a/src/services/agent-environment/proxy-environment.ts b/src/services/agent-environment/proxy-environment.ts index dd7cdeee3..530baba2c 100644 --- a/src/services/agent-environment/proxy-environment.ts +++ b/src/services/agent-environment/proxy-environment.ts @@ -1,5 +1,6 @@ import { WrapperConfig } from '../../types'; import { NetworkConfig } from '../squid-service'; +import { buildNoProxyValue } from '../no-proxy-utils'; interface ProxyEnvironmentParams { config: WrapperConfig; @@ -10,21 +11,21 @@ interface ProxyEnvironmentParams { export function buildProxyEnvironment(params: ProxyEnvironmentParams): void { const { config, networkConfig, environment } = params; - environment.NO_PROXY = `localhost,127.0.0.1,::1,0.0.0.0,${networkConfig.squidIp},${networkConfig.agentIp}`; - environment.no_proxy = environment.NO_PROXY; + const noProxyHosts: string[] = ['0.0.0.0', networkConfig.squidIp, networkConfig.agentIp]; if (config.enableHostAccess) { const subnetBase = networkConfig.subnet.split('/')[0]; const parts = subnetBase.split('.'); const networkGatewayIp = `${parts[0]}.${parts[1]}.${parts[2]}.1`; - environment.NO_PROXY += `,host.docker.internal,${networkGatewayIp}`; - environment.no_proxy = environment.NO_PROXY; + noProxyHosts.push('host.docker.internal', networkGatewayIp); } if (config.enableApiProxy && networkConfig.proxyIp) { // Include both IP and Docker service hostname — Node.js undici matches // NO_PROXY against the request hostname string, not the resolved IP. - environment.NO_PROXY += `,${networkConfig.proxyIp},api-proxy`; - environment.no_proxy = environment.NO_PROXY; + noProxyHosts.push(networkConfig.proxyIp, 'api-proxy'); } + + environment.NO_PROXY = buildNoProxyValue(noProxyHosts); + environment.no_proxy = environment.NO_PROXY; } diff --git a/src/services/api-proxy-env-config.ts b/src/services/api-proxy-env-config.ts index c35461abf..64f2d945a 100644 --- a/src/services/api-proxy-env-config.ts +++ b/src/services/api-proxy-env-config.ts @@ -4,6 +4,7 @@ import { WrapperConfig } from '../types'; import { getConfigEnvValue, getLowerCaseProcessEnvValue, pickEnvVars } from '../env-utils'; import { OPENAI_ENV, ANTHROPIC_ENV, GEMINI_ENV, COPILOT_ENV, VERTEX_ENV, OIDC_AUTH_ENV_VARS, OIDC_AUTH_ENV_MAPPING } from '../api-proxy-env-constants'; import { NetworkConfig } from './squid-service'; +import { buildNoProxyEnv } from './no-proxy-utils'; const DEFAULT_API_PROXY_SHUTDOWN_TIMEOUT_MS = 8000; @@ -141,8 +142,7 @@ function buildProxyRoutingEnv(networkConfig: NetworkConfig): Record