Skip to content

Anthropic API not working #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Luximora opened this issue Nov 7, 2024 · 0 comments
Open

Anthropic API not working #61

Luximora opened this issue Nov 7, 2024 · 0 comments

Comments

@Luximora
Copy link

Luximora commented Nov 7, 2024

Describe the bug
When I use the anthropic API I get this error:

{"type":"error","error":{"type":"authentication_error","message":"CORS requests must set 'anthropic-dangerous-direct-browser-access' header"}}

Desktop (please complete the following information):

  • OS: Windows
  • Browser : Edge

I looked into anthropic's documentation to see what it was about and found this:

The anthropic-dangerous-direct-browser-access header is automatically added when using the dangerouslyAllowBrowser option in the TypeScript SDK (1) . Here's how to enable it:

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: null,
  dangerouslyAllowBrowser: true
});

Note that enabling browser support is considered dangerous because it could expose your secret API credentials in client-side code (2) . Web browsers are inherently less secure than server environments, as any user with access to the browser can potentially inspect, extract, and misuse these credentials .

Some scenarios where enabling browser support might be acceptable include :

  • Internal tools used within a controlled environment with trusted users
  • Development or debugging purposes with temporary/frequently rotated credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant