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 <noreply@anthropic.com>
This commit is contained in:
parent
7f2fc153b5
commit
f87c089ca2
|
|
@ -34,13 +34,20 @@ export class ClaudeAgentService implements OnModuleInit {
|
||||||
|
|
||||||
onModuleInit() {
|
onModuleInit() {
|
||||||
const baseUrl = this.configService.get<string>('ANTHROPIC_BASE_URL');
|
const baseUrl = this.configService.get<string>('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({
|
this.client = new Anthropic({
|
||||||
apiKey: this.configService.get<string>('ANTHROPIC_API_KEY'),
|
apiKey: this.configService.get<string>('ANTHROPIC_API_KEY'),
|
||||||
baseURL: baseUrl || undefined,
|
baseURL: baseUrl || undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (baseUrl) {
|
if (baseUrl && !isProxyUrl) {
|
||||||
console.log(`Using Anthropic API base URL: ${baseUrl}`);
|
console.log(`Using Anthropic API base URL: ${baseUrl}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue