Security

CORS

Last updated: February 16, 2026

CORS (Cross-Origin Resource Sharing) is a browser security mechanism that controls which web domains are allowed to make requests to your server. By default, browsers block web pages from making HTTP requests to a different origin (domain, protocol, or port) than the one that served the page. CORS headers tell the browser which cross-origin requests to permit.

Why It Matters

When you host an AI assistant's control UI on one domain and its API gateway on another, or when a frontend application on app.example.com needs to communicate with an API on api.example.com, the browser will block those requests unless the server explicitly allows them through CORS headers. Misconfigured CORS can either break legitimate functionality or, if overly permissive, expose your API to unauthorized access from malicious websites.

How It Works

CORS operates through HTTP headers exchanged between the browser and server. When a web page makes a cross-origin request, the browser first sends a preflight request (an HTTP OPTIONS request) to the target server. The server responds with headers like Access-Control-Allow-Origin, Access-Control-Allow-Methods, and Access-Control-Allow-Headers to specify what is permitted. If the server's response matches the browser's request requirements, the actual request proceeds. Otherwise, the browser blocks it.

In a reverse proxy architecture, CORS complexity is often eliminated entirely. When the proxy serves both the frontend UI and the API from the same origin, all requests are same-origin and CORS does not apply. This is one of the key advantages of fronting an AI gateway with a reverse proxy on a single public domain.

In Practice

If your deployment requires cross-origin access, configure CORS headers on your gateway or proxy to allow only specific trusted origins. Avoid using the wildcard * for Access-Control-Allow-Origin when credentials are involved. When debugging CORS errors, inspect the browser's network tab for preflight request failures and verify that your server responds correctly to OPTIONS requests.