[BUG] Desktop Code tab ignores ANTHROPIC_BASE_URL from ~/.claude/settings.json (terminal CLI honors it)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Sessions started from the Claude desktop app's Code tab always send API traffic to https://api.anthropic.com, ignoring env.ANTHROPIC_BASE_URL in ~/.claude/settings.json. The terminal claude CLI, reading the same settings file, routes to the configured endpoint as expected.
The desktop app spawns the bundled claude process with ANTHROPIC_BASE_URL=https://api.anthropic.com in its environment (confirmed by inspecting the spawned process's environment). Although the session loads user settings (--setting-sources=user,project,local), the injected value wins over the settings file. There is no desktop app setting to change it, so there is no supported way to put a local proxy in front of Code tab sessions.
What Should Happen?
Code tab sessions should honor env.ANTHROPIC_BASE_URL from user settings, the same way the terminal CLI does.
If the pinning is intentional (e.g. to protect how the host delivers the OAuth token), please either offer an opt-in setting that allows a user-approved local endpoint (127.0.0.1 / localhost), or document that the Code tab does not support custom base URLs.
Error Messages/Logs
No error is shown — traffic silently bypasses the configured endpoint.
Spawned Code tab process environment (relevant part):
ANTHROPIC_BASE_URL=https://api.anthropic.com
CLAUDE_CODE_ENTRYPOINT=claude-desktop
Local proxy request counter (Prometheus metric):
- Before terminal test: headroom_requests_total 26
- After one terminal `claude -p` call: headroom_requests_total 28 (0 failed)
- After several further Code tab turns: headroom_requests_total 28 (unchanged)
Steps to Reproduce
- Run any local Anthropic-compatible proxy that counts requests, e.g. on
http://127.0.0.1:6767. - Add to
~/.claude/settings.json:
``json``
{ "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:6767" } }
- In a terminal, run
claude -p "hi"→ the proxy's request counter increments. ✅ - Open the Claude desktop app → Code tab → start a session and send a few messages → the proxy's counter does not change. ❌
- Optionally, from a Bash tool call inside the Code tab session, run
echo $ANTHROPIC_BASE_URL→ printshttps://api.anthropic.com.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.281 (bundled in Claude desktop app 2.9939.2, Code tab); terminal CLI 2.1.283 behaves correctly
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
- Claude desktop app 2.9939.2, macOS 27.0 (26A428), Apple Silicon (arm64)
- Signed in with a Claude subscription (OAuth), not an API key
- The Code tab is launched by the desktop app, not from a terminal, hence "Other" for Terminal/Shell.
- Related (different symptom, same root observation that the desktop app always injects
ANTHROPIC_BASE_URL): #81973 - Use case: local token-compression / observability proxies (Headroom in my case), which work with the terminal CLI but cannot be used from the Code tab today.
Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
Thanks for the clean repro — especially the process-env check (
ANTHROPIC_BASE_URL=https://api.anthropic.comon the Code-tab spawn) and the proxy counter that stays flat while the terminal CLI increments. That pins this as host injection winning overenvfrom~/.claude/settings.json, not a settings-load miss (--setting-sources=user,project,localis already set).Suggestion for the team: resolve the effective endpoint through one shared configuration-precedence path for CLI and Desktop Code tab. If Desktop must pin the OAuth endpoint for token delivery, reject the conflicting user setting visibly (or document “unsupported on Code tab”) instead of silently overriding it. Endpoint provenance in diagnostics would help a lot here: effective value, winning source, and any overridden source.
Regression idea: launch a terminal CLI session and a Code-tab session from the same
settings.jsonwith a local proxyANTHROPIC_BASE_URL, then assert either identical routing or an explicit unsupported-setting error — never silent bypass.Happy to refine if you’ve already got a documented intentional pin for OAuth hosts.
Same issue here, and a few extra data points that may help narrow it down.
Environment: macOS 15.6 (arm64), Claude desktop 2.9939.2, Code tab CLI 2.1.281, terminal CLI 2.1.278, claude.ai subscription (OAuth). The proxy is a self-hosted Headroom instance reachable only over VPN;
~/.claude/settings.jsonhas"env": {"ANTHROPIC_BASE_URL": "http://<proxy>/llm"}.1. A process env var beats the settings
envblock, even in the terminal CLI. I counted requests in the proxy's access log:So the settings
envonly fills in variables that aren't set yet. That contradicts llm-gateway-connect: "When both a shell export and a settings-fileenvblock set the same variable, the settings-file value applies." Because the desktop app always passesANTHROPIC_BASE_URL=https://api.anthropic.comto its sessions, no settings file can change the destination. That includes managed settings, if they follow the same rule.2. SSH environments don't help either. For an SSH environment (I pointed one at the same Mac), the app installs its server under
~/.claude/remote/srv/…and the CLI under~/.claude/remote/ccd-cli/<version>on the remote side. It then launches the CLI with the sameANTHROPIC_BASE_URL=https://api.anthropic.com(plusCLAUDE_CODE_OAUTH_TOKEN). The remote user'ssettings.jsonloses the same way as in point 1.3. Third-party inference is not an alternative for subscription users. The gateway provider in "Configure Third-Party Inference" switches the whole app into 3P mode. That means not signing in to Anthropic (per the installation docs), so no subscription. We just want the Code tab to send the same subscription OAuth traffic through our own proxy, which the terminal CLI already does.
Workaround (unsupported, breaks on every CLI update): an SSH environment to
127.0.0.1plus a wrapper in place of~/.claude/remote/ccd-cli/<version>that runsunset ANTHROPIC_BASE_URLand thenexecs the real binary. After that the settings value applies, and the proxy log showsclaude-cli/2.1.281 (external, claude-desktop)requests with 200s. A launchdWatchPathsagent re-wraps new versions. It works, but it's clearly not something anyone should need.What would fix it for us: either don't inject
ANTHROPIC_BASE_URLwhen the user's settings define one, or add an explicit opt-in (for example an allowlist of base URLs) for Code-tab sessions, local and SSH. Separately, please either fix the precedence described in point 1 or correct the docs.Reproduced on Windows 11 as well, so this does not look macOS-specific.
Environment
Setup
~/.claude/settings.json(C:\Users\<user>\.claude\settings.json):A local compression proxy (Headroom 0.39.1) listens on 127.0.0.1:8787 and exposes request counters at
/stats.Result
$env:ANTHROPIC_BASE_URLin the session shell ishttps://api.anthropic.com, not the value from settings.json. The proxy receives no/v1/messagesrequests (request counter unchanged).claudewith noANTHROPIC_BASE_URLin the parent environment: the settings.json value is honored. Counter went 2 -> 4 for oneclaude -pcall, and OAuth works through the proxy.claudewithANTHROPIC_BASE_URL=https://api.anthropic.comset in the parent environment: settings.json is not applied (counter unchanged). This matches the usual "process env wins over settings.json" precedence, and it shows the cause is the desktop app injecting that variable into the spawned process.Conclusion
Same as the macOS report: the Code tab spawns the agent with
ANTHROPIC_BASE_URL=https://api.anthropic.com, which takes precedence overenv.ANTHROPIC_BASE_URLin settings.json. There is no setting in the desktop app to change it, so a local proxy cannot be placed in front of Code tab sessions on Windows either.Use case
Putting a local context-compression / caching proxy (e.g. Headroom, LiteLLM-style gateways) in front of sessions. The terminal CLI and VS Code extension work. The desktop Code tab is the only client that cannot.
Request
Either honor a user-configured
ANTHROPIC_BASE_URL(settings.jsonenvor an app setting) in the Code tab, or document that it is unsupported.Related: headroomlabs-ai/headroom#869 (same behavior reported on macOS, from the proxy side).