Skip to content

Commit 46c5b33

Browse files
committed
v1.2.1: fix env var conflict — ANTHROPIC_API_KEY overrides plugin fetch
When ANTHROPIC_API_KEY is set in the environment, the SDK ignores the plugin's custom fetch and makes direct requests (no ?beta=true, no OAuth headers). Fix: use authToken instead of apiKey, and temporarily clear the env var during OAuth sessions.
1 parent e7ef086 commit 46c5b33

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-claude-bridge",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "OpenCode ↔ Claude bridge — keychain sync + PKCE OAuth + request transformation",
55
"type": "module",
66
"main": "dist/index.js",

src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,13 @@ const AnthropicOAuthCombined = async ({ client }: { client: PluginClient }) => {
155155
};
156156
}
157157

158+
// Temporarily clear env var so SDK doesn't use it over our OAuth token
159+
const savedApiKey = process.env.ANTHROPIC_API_KEY;
160+
delete process.env.ANTHROPIC_API_KEY;
161+
158162
return {
159-
// Empty apiKey tells SDK not to set x-api-key; our fetch sets Bearer
160-
apiKey: "",
163+
// authToken tells SDK to use Authorization: Bearer (skips x-api-key)
164+
authToken: auth.access,
161165

162166
async fetch(
163167
input: string | URL | Request,

0 commit comments

Comments
 (0)