CORS and calls from the browser
1 min read
If you call the API directly from the browser (frontend), there are a few things to know:
- Use a public key, not a live key — a live key must never sit in code the user can see.
- Lock the public key to your domain (origin allowlist, e.g.
https://example.com). This is required: without domains every call is rejected. Calls from other domains are rejected with 403 and a message saying the origin isn't on the allowlist. Add the domain under the key's Configuration → Allowed origins. - If you get an actual CORS error in the browser, check your headers: from the browser you may only send
AuthorizationandContent-Type. Other custom headers (e.g.X-Addr-Key) are rejected by the browser's preflight.
If the call should ideally not be visible to the user (e.g. sensitive lookups), make it from your server with a live key instead.
Was this helpful?
