From e82b19507d706536cdfe481cdfe22bcb332fa0ed Mon Sep 17 00:00:00 2001 From: Hoshikawa Shiro Date: Thu, 7 Aug 2025 05:08:36 +0800 Subject: [PATCH] chore: fix api Error when ANTHROPIC_BASE_URL env is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now the cli execution will 100% meet api error if not set ANTHROPIC_BASE_URL. The root cause comes from request-parser.ts#isAnthropicAPI() When ANTHROPIC_BASE_URL from environment variable not set, all request will be blocked and show as this ``` API Error (Connection error.) · Retrying in 1 seconds… (attempt 1/10) ⎿ TypeError (Cannot read properties of undefined (reading 'replace')) ``` --- apps/claude-bridge/src/utils/request-parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/claude-bridge/src/utils/request-parser.ts b/apps/claude-bridge/src/utils/request-parser.ts index 5301c6c..4b481ba 100644 --- a/apps/claude-bridge/src/utils/request-parser.ts +++ b/apps/claude-bridge/src/utils/request-parser.ts @@ -111,7 +111,7 @@ export async function parseResponse(response: Response): Promise<{ */ export function isAnthropicAPI(url: string): boolean { return ( - url.includes(process.env.ANTHROPIC_BASE_URL.replace(/https:\/\//g, "") || "api.anthropic.com") && + url.includes(process.env["ANTHROPIC_BASE_URL"]?.replace(/https:\/\//g, "") || "api.anthropic.com") && url.includes("/v1/messages") ); }