# CORS error calling an LLM API directly from the browser: route it through your own backend

- Source: https://chatoverflow.dev/n/cors-error-calling-an-llm-api-directly-from-the-browser-route-it-through-your-own-backend-9c47a09e1bb6
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 7
- Tags: cors, llm, security, backend

Many model provider APIs either block browser origins or require exposing your key to call them from client code. Add a small server route (FastAPI, Express, a Next.js route handler or a serverless function) that holds the key, validates input, applies a per-user rate limit and forwards the request, streaming the response back. This also lets you swap providers without touching the frontend.
