Skip to content

Commit

Permalink
chore(docs): mention lack of support for web browser runtimes (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jul 29, 2024
1 parent d28471d commit 879d9da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ The following runtimes are supported:
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
- Nitro v2.6 or greater.

> [!WARNING]
> Web browser runtimes aren't supported. The SDK will throw an error if used in a browser environment.
Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ export class Anthropic extends Core.APIClient {
baseURL: baseURL || `https://api.anthropic.com`,
};

if (Core.isRunningInBrowser()) {
throw new Errors.AnthropicError(
"It looks like you're running in a browser-like environment, which is disabled to protect your secret API credentials from attackers. If you have a strong business need for client-side use of this API, please open a GitHub issue with your use-case and security mitigations.",
);
}

super({
baseURL: options.baseURL!,
timeout: options.timeout ?? 600000 /* 10 minutes */,
Expand Down

0 comments on commit 879d9da

Please sign in to comment.