2 Commits

Author SHA1 Message Date
Elie Habib
cf5328f2d4 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.
2026-03-30 11:08:14 +04:00
Nicolas Gomes Ferreira Dos Santos
21f3e802ac perf(api): split monolithic edge function into per-domain functions (#753)
* perf(api): split monolithic edge function into per-domain functions

The catch-all api/[domain]/v1/[rpc].ts eagerly imported all 21 domain
handlers and their dependencies (~93 modules) on every cold start,
even though each request only targets one domain.

Split into 21 per-domain edge functions (api/seismology/v1/[rpc].ts,
api/market/v1/[rpc].ts, etc.) so Vercel bundles each domain separately.
Cold start now only loads the code for the requested domain (~1/21th).

- Extract shared gateway logic (CORS, rate limiting, API key validation,
  POST→GET compat, error boundary, cache tiers) into server/gateway.ts
- Create 21 thin domain files that each import only their own handler
- Reduce catch-all to a lightweight 404 for unknown domains

Closes #179.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(gateway): remove duplicate process declaration and use canonical ServerOptions type

- Remove local `declare const process` — already in server/env.d.ts (PR #752)
- Import ServerOptions from generated service_server instead of redefining a subset
- Document centralised RPC_CACHE_TIER trade-off
- Annotate empty catch in POST→GET compat path

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Elie Habib <elie.habib@gmail.com>
2026-03-02 14:13:34 +04:00