feat: pass ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN into agent containers
Users with a custom Anthropic-compatible endpoint (ANTHROPIC_BASE_URL) were getting 401s because the OneCLI proxy injects ANTHROPIC_API_KEY=placeholder and forwards to api.anthropic.com, overriding the custom endpoint and key. Add a claude provider host config that reads ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC from .env and passes them into the container. Also sets NO_PROXY for the custom host so the OneCLI proxy doesn't intercept those requests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
src/providers/claude.ts
Normal file
16
src/providers/claude.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { readEnvFile } from '../env.js';
|
||||||
|
import { registerProviderContainerConfig } from './provider-container-registry.js';
|
||||||
|
|
||||||
|
registerProviderContainerConfig('claude', () => {
|
||||||
|
const dotenv = readEnvFile(['ANTHROPIC_BASE_URL', 'ANTHROPIC_AUTH_TOKEN', 'CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC']);
|
||||||
|
const env: Record<string, string> = {};
|
||||||
|
if (dotenv.ANTHROPIC_BASE_URL) {
|
||||||
|
env.ANTHROPIC_BASE_URL = dotenv.ANTHROPIC_BASE_URL;
|
||||||
|
const host = new URL(dotenv.ANTHROPIC_BASE_URL).hostname;
|
||||||
|
env.NO_PROXY = host;
|
||||||
|
env.no_proxy = host;
|
||||||
|
}
|
||||||
|
if (dotenv.ANTHROPIC_AUTH_TOKEN) env.ANTHROPIC_AUTH_TOKEN = dotenv.ANTHROPIC_AUTH_TOKEN;
|
||||||
|
if (dotenv.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC) env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = dotenv.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC;
|
||||||
|
return { env };
|
||||||
|
});
|
||||||
@@ -4,3 +4,4 @@
|
|||||||
// needs (claude, mock) don't appear here.
|
// needs (claude, mock) don't appear here.
|
||||||
//
|
//
|
||||||
// Skills add a new provider by appending one import line below.
|
// Skills add a new provider by appending one import line below.
|
||||||
|
import './claude.js';
|
||||||
|
|||||||
Reference in New Issue
Block a user