Skip to content

Commit 879d9da

Browse files
chore(docs): mention lack of support for web browser runtimes (#468)
1 parent d28471d commit 879d9da

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ The following runtimes are supported:
419419
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
420420
- Nitro v2.6 or greater.
421421

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

424427
If you are interested in other runtime environments, please open or upvote an issue on GitHub.

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ export class Anthropic extends Core.APIClient {
109109
baseURL: baseURL || `https://api.anthropic.com`,
110110
};
111111

112+
if (Core.isRunningInBrowser()) {
113+
throw new Errors.AnthropicError(
114+
"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.",
115+
);
116+
}
117+
112118
super({
113119
baseURL: options.baseURL!,
114120
timeout: options.timeout ?? 600000 /* 10 minutes */,

0 commit comments

Comments
 (0)