- Symptom
- It looks like you're running in a browser-like environment. This is disabled by default, as it risks exposing your secret API credentials to attackers.fetch to api.anthropic.com from a web page is blocked by CORS
- Cause
- The TypeScript SDK refuses to run in a browser unless dangerouslyAllowBrowser is set, and the API grants cross-origin requests only when the anthropic-dangerous-direct-browser-access header is present, which that option adds.
- Fix
- Call the API from a server route and keep the key there. Only for bring-your-own-key tools where the user supplies their own key, set dangerouslyAllowBrowser true.
- Apply
const client = new Anthropic({ apiKey: userSuppliedKey, dangerouslyAllowBrowser: true }); // raw fetch: add header 'anthropic-dangerous-direct-browser-access': 'true'- Affected
- @anthropic-ai/sdk 0.27.0 and later, as of 2026-10
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders