claude-code - 💡(How to fix) Fix [FEATURE] Make OAuth/admin base URL configurable like ANTHROPIC_BASE_URL [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48011Fetched 2026-04-15 06:35:53
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
commented ×2labeled ×2

Fix Action

Fix / Workaround

  • CLAUDE_CODE_CUSTOM_OAUTH_URL exists but is restricted to an internal allowlist of Anthropic-owned URLs.
  • #22992 — device-code auth for headless environments (different approach, same audience — multiple commenters noted that CLAUDE_CODE_OAUTH_TOKEN workaround loses subscription features like usage display and connectors)
  • PR #5490 — containerized Claude Code with host credential delegation (discussion touched on dynamic credential replacement in the forwarding layer)
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

ANTHROPIC_BASE_URL correctly routes inference calls through custom endpoints, but ~30 OAuth and admin endpoints (/api/oauth/*, /api/claude_code/*, /v1/sessions/*, /v1/mcp_servers, event logging, etc.) use a hardcoded BASE_API_URL (https://api.anthropic.com) that ignores any configured base URL. API key authentication already works cleanly, ANTHROPIC_BASE_URL is respected across the board, but the OAuth path lacks the same configurability.

Proposed Solution

Remove the allowlist restriction on CLAUDE_CODE_CUSTOM_OAUTH_URL so it accepts arbitrary URLs, bringing OAuth endpoint routing to parity with how ANTHROPIC_BASE_URL already works for inference.

Alternative Solutions

  • Add a new env var (e.g. ANTHROPIC_OAUTH_BASE_URL) specifically for non-inference endpoints.
  • The recent addition of custom TLS certificate support makes MITM approaches easier, but delegating authentication to a gateway that injects credentials without breaking the in-container chain of trust is a cleaner solution than TLS interception.

Priority

Medium - Would be very helpful

Feature Category

Configuration and settings

Use Case Example

We run interactive containerized Claude Code agents (like a secure sandbox for your personal AI coding agent on your own dev machine - similar to Docker Sandboxes, but based on podman) with a host-side credential gateway that swaps phantom tokens for real credentials (terok-sandbox). This works perfectly for API key auth via ANTHROPIC_BASE_URL, for OAuth, the credential gateway can even correctly request and obtain OAuth key refreshes adn route the inference path from the container to the Anthropic servers without revealing the real credentials inside the container, but the hardcoded OAuth endpoints bypass it, breaking subscription features (usage, profile, settings, connectors).

Additional Context

  • CLAUDE_CODE_CUSTOM_OAUTH_URL exists but is restricted to an internal allowlist of Anthropic-owned URLs.
  • #22992 — device-code auth for headless environments (different approach, same audience — multiple commenters noted that CLAUDE_CODE_OAUTH_TOKEN workaround loses subscription features like usage display and connectors)
  • PR #5490 — containerized Claude Code with host credential delegation (discussion touched on dynamic credential replacement in the forwarding layer)

extent analysis

TL;DR

Remove the allowlist restriction on CLAUDE_CODE_CUSTOM_OAUTH_URL to enable configurable OAuth endpoint routing.

Guidance

  • Review the current implementation of CLAUDE_CODE_CUSTOM_OAUTH_URL and assess the feasibility of removing the allowlist restriction.
  • Consider adding a new environment variable, such as ANTHROPIC_OAUTH_BASE_URL, as an alternative solution to provide a separate configuration option for non-inference endpoints.
  • Evaluate the potential security implications of allowing arbitrary URLs for OAuth endpoint routing and ensure that proper validation and sanitization are in place.
  • Investigate the use of a credential gateway, as mentioned in the terok-sandbox example, to delegate authentication and maintain a secure chain of trust.

Example

No code snippet is provided as the issue focuses on configuration and architectural changes rather than specific code implementations.

Notes

The proposed solution requires careful consideration of security implications and potential vulnerabilities introduced by allowing arbitrary URLs for OAuth endpoint routing. Additionally, the alternative solutions, such as adding a new environment variable, may require further discussion and evaluation.

Recommendation

Apply the workaround by removing the allowlist restriction on CLAUDE_CODE_CUSTOM_OAUTH_URL, as it appears to be the most direct solution to enable configurable OAuth endpoint routing, while ensuring proper security measures are in place.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING