From f87c089ca27b355399cbc59f91218bc6f5627589 Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 9 Jan 2026 20:50:15 -0800 Subject: [PATCH] fix: disable TLS verification for IP-based proxy When ANTHROPIC_BASE_URL points to an IP address (proxy server), disable TLS certificate verification to allow connection. Co-Authored-By: Claude Opus 4.5 --- .../src/infrastructure/claude/claude-agent.service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/services/conversation-service/src/infrastructure/claude/claude-agent.service.ts b/packages/services/conversation-service/src/infrastructure/claude/claude-agent.service.ts index 5bb739b..cf46ea2 100644 --- a/packages/services/conversation-service/src/infrastructure/claude/claude-agent.service.ts +++ b/packages/services/conversation-service/src/infrastructure/claude/claude-agent.service.ts @@ -34,13 +34,20 @@ export class ClaudeAgentService implements OnModuleInit { onModuleInit() { const baseUrl = this.configService.get('ANTHROPIC_BASE_URL'); + const isProxyUrl = baseUrl && (baseUrl.includes('67.223.119.33') || baseUrl.match(/^\d+\.\d+\.\d+\.\d+/)); + + // If using IP-based proxy, disable TLS certificate verification + if (isProxyUrl) { + console.log(`Using Anthropic proxy (TLS verification disabled): ${baseUrl}`); + process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; + } this.client = new Anthropic({ apiKey: this.configService.get('ANTHROPIC_API_KEY'), baseURL: baseUrl || undefined, }); - if (baseUrl) { + if (baseUrl && !isProxyUrl) { console.log(`Using Anthropic API base URL: ${baseUrl}`); }