Configure exact CORS origin policies for browser clients
Allow your production domains and preview deployments to call endpoints cleanly while blocking unauthorized third-party sites.
Steps to configure safe browser CORS policies
- 01
Avoid bare wildcard origins
Specify exact https origins instead of Access-Control-Allow-Origin: * on authenticated routes.
- 02
Support staging preview subdomains
Add scoped wildcard patterns restricted strictly to your team's verified preview domain suffix.
- 03
Expose quota headers to JS
List custom rate-limit or trace headers in Access-Control-Expose-Headers so Fetch can read them.
- 04
Remember CORS is not auth
Always pair CORS browser policies with JWT validation or rate-limited public shields.
Common questions
Why shouldn't I just turn on wildcard CORS to fix browser errors?
Wildcards let arbitrary third-party web pages attempt cross-origin calls against your endpoints. Exact origin lists tighten browser boundaries.
Do I need to configure OPTIONS preflight handlers manually?
No. APIkit handles CORS preflight OPTIONS responses automatically at the edge based on your origin rules.
Can our frontend JavaScript read rate-limit and trace ID headers?
Yes. Adding custom headers to Access-Control-Expose-Headers makes them accessible inside browser fetch responses.
Related tasks in this category
See all in API Key Auth, Scopes & Quotas-
Issue scoped API keys per customer and environment
Generate prefixed keys restricted to specific endpoints, read-only routes, or workspaces—no custom auth database required.
-
Meter and cap monthly token quotas per tenant
Track exact prompt and completion token usage per workspace, warn at 80%, and enforce clean monthly caps without building Stripe metering pipelines.
-
Rotate API keys smoothly with overlapping grace windows
Issue replacement API keys with a configurable 24-hour or 7-day overlap window so mobile workers and cron jobs migrate without outages.
-
Verify end-user JWT claims directly at your AI endpoint
Let web or mobile apps pass Auth0, Clerk, or Supabase JWTs straight to APIkit—verifying signatures and claims without a proxy server.
-
Lock internal AI endpoints to approved IP and CIDR ranges
Ensure B2B partner integrations and internal admin pipelines only accept traffic from static VPN, VPC NAT, or enterprise IP blocks.
-
Shield public unauthenticated AI forms from bot abuse
Keep interactive landing-page demos and public lead widgets safe from scripted prompt drain using origin checks, payload caps, and Turnstile tokens.