From cf5328f2d4626cf7cc506e69bb0345db332e27e3 Mon Sep 17 00:00:00 2001 From: Elie Habib Date: Mon, 30 Mar 2026 11:08:14 +0400 Subject: [PATCH] fix(llm): pin LLM edge functions to US/EU regions to prevent geo-block 403s (#2541) OpenRouter returns 403 'This model is not available in your region' when Vercel routes through edge nodes in regions where Google Gemini is blocked. Pin chat-analyst, news, and intelligence edge functions to iad1/lhr1/fra1/sfo1. Also improves error logging in callLlmReasoningStream to include model name and full response body on non-2xx for easier future diagnosis. --- api/chat-analyst.ts | 2 +- api/intelligence/v1/[rpc].ts | 2 +- api/news/v1/[rpc].ts | 2 +- server/_shared/llm.ts | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/chat-analyst.ts b/api/chat-analyst.ts index d00a61b79..e089cd5ec 100644 --- a/api/chat-analyst.ts +++ b/api/chat-analyst.ts @@ -11,7 +11,7 @@ * data: {"error":"..."} — on auth/llm failure */ -export const config = { runtime: 'edge' }; +export const config = { runtime: 'edge', regions: ['iad1', 'lhr1', 'fra1', 'sfo1'] }; // @ts-expect-error — JS module, no declaration file import { getCorsHeaders } from './_cors.js'; diff --git a/api/intelligence/v1/[rpc].ts b/api/intelligence/v1/[rpc].ts index 5f7a67bd3..61ee7a179 100644 --- a/api/intelligence/v1/[rpc].ts +++ b/api/intelligence/v1/[rpc].ts @@ -1,4 +1,4 @@ -export const config = { runtime: 'edge' }; +export const config = { runtime: 'edge', regions: ['iad1', 'lhr1', 'fra1', 'sfo1'] }; import { createDomainGateway, serverOptions } from '../../../server/gateway'; import { createIntelligenceServiceRoutes } from '../../../src/generated/server/worldmonitor/intelligence/v1/service_server'; diff --git a/api/news/v1/[rpc].ts b/api/news/v1/[rpc].ts index 72dcfc08f..a0a498a0d 100644 --- a/api/news/v1/[rpc].ts +++ b/api/news/v1/[rpc].ts @@ -1,4 +1,4 @@ -export const config = { runtime: 'edge' }; +export const config = { runtime: 'edge', regions: ['iad1', 'lhr1', 'fra1', 'sfo1'] }; import { createDomainGateway, serverOptions } from '../../../server/gateway'; import { createNewsServiceRoutes } from '../../../src/generated/server/worldmonitor/news/v1/service_server'; diff --git a/server/_shared/llm.ts b/server/_shared/llm.ts index a1b628300..5fdcd3e4a 100644 --- a/server/_shared/llm.ts +++ b/server/_shared/llm.ts @@ -293,7 +293,8 @@ export function callLlmReasoningStream(opts: LlmStreamOptions): ReadableStream '') : ''; + console.warn(`[llm-stream:${providerName}] HTTP ${resp.status} model=${creds.model} body=${errBody.slice(0, 300)}`); continue; }