Skip to content

Commit cf5328f

Browse files
authored
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.
1 parent bf27e47 commit cf5328f

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

api/chat-analyst.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* data: {"error":"..."} — on auth/llm failure
1212
*/
1313

14-
export const config = { runtime: 'edge' };
14+
export const config = { runtime: 'edge', regions: ['iad1', 'lhr1', 'fra1', 'sfo1'] };
1515

1616
// @ts-expect-error — JS module, no declaration file
1717
import { getCorsHeaders } from './_cors.js';

api/intelligence/v1/[rpc].ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const config = { runtime: 'edge' };
1+
export const config = { runtime: 'edge', regions: ['iad1', 'lhr1', 'fra1', 'sfo1'] };
22

33
import { createDomainGateway, serverOptions } from '../../../server/gateway';
44
import { createIntelligenceServiceRoutes } from '../../../src/generated/server/worldmonitor/intelligence/v1/service_server';

api/news/v1/[rpc].ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const config = { runtime: 'edge' };
1+
export const config = { runtime: 'edge', regions: ['iad1', 'lhr1', 'fra1', 'sfo1'] };
22

33
import { createDomainGateway, serverOptions } from '../../../server/gateway';
44
import { createNewsServiceRoutes } from '../../../src/generated/server/worldmonitor/news/v1/service_server';

server/_shared/llm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ export function callLlmReasoningStream(opts: LlmStreamOptions): ReadableStream<U
293293

294294
if (!resp.ok || !resp.body) {
295295
clearTimeout(timeoutId);
296-
console.warn(`[llm-stream:${providerName}] HTTP ${resp.status}`);
296+
const errBody = resp.body ? await resp.text().catch(() => '') : '';
297+
console.warn(`[llm-stream:${providerName}] HTTP ${resp.status} model=${creds.model} body=${errBody.slice(0, 300)}`);
297298
continue;
298299
}
299300

0 commit comments

Comments
 (0)