[BUG] Host Header is overriden with Base URL

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 4 comments · opened Jun 17, 2025 · closed Aug 19, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [x] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.25
  • Operating System: Ubuntu 22.04
  • Terminal: iTerm2

Bug Description

Even when Host header is supplied via ANTHROPIC_CUSTOM_HEADERS, it gets overridden by ANTHROPIC_BEDROCK_BASE_URL in the request header.

Steps to Reproduce

  1. Set the following as config

```
{
"env": {
"ANTHROPIC_CUSTOM_HEADERS": "host: foo.com",
"CLAUDE_CODE_USE_BEDROCK": "1",
"CLAUDE_CODE_SKIP_BEDROCK_AUTH": "1",
"ANTHROPIC_BEDROCK_BASE_URL": "http://localhost:8080"
}
}


2. Run Claude code and say "hey"
3. Observe the request received on localhost:8080

## Expected Behavior
The host header is set to `foo.com`

## Actual Behavior
The host header is set to `localhost:8080`


## Additional Context

With debug log turned on, the following logs are shown

[log_7e992a] sending request {
method: 'post',
url: 'http://localhost:8080/model/us.anthropic.claude-3-7-sonnet-20250219-v1:0/invoke-with-response-stream',
options: {
method: 'post',
path: '/model/us.anthropic.claude-3-7-sonnet-20250219-v1:0/invoke-with-response-stream',
body: {
model: undefined,
messages: [Array],
temperature: 1,
system: [Array],
tools: [Array],
tool_choice: undefined,
metadata: [Object],
max_tokens: 32000,
thinking: undefined,
stream: undefined,
anthropic_version: 'bedrock-2023-05-31',
anthropic_beta: [Array]
},
timeout: 60000,
signal: AbortSignal { aborted: false },
stream: true,
__streamClass: [class OV1 extends xD]
},
headers: {
accept: 'application/json',
'anthropic-beta': 'claude-code-20250219',
'anthropic-dangerous-direct-browser-access': 'true',
'anthropic-version': '2023-06-01',
'content-type': 'application/json',
host: 'foo.com',
'user-agent': 'claude-cli/1.0.25 (external, cli)',
'x-app': 'cli',
'x-stainless-arch': 'x64',
'x-stainless-helper-method': 'stream',
'x-stainless-lang': 'js',
'x-stainless-os': 'Linux',
'x-stainless-package-version': '0.51.0',
'x-stainless-retry-count': '0',
'x-stainless-runtime': 'node',
'x-stainless-runtime-version': 'v22.16.0',
'x-stainless-timeout': '60'
}
}

View original on GitHub ↗

4 Comments

github-actions[bot] · 1 year ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] · 10 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 10 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

bcherny collaborator · 1 month ago

Tested this on Claude Code 2.1.233 (Linux) with your exact config: a local capture server on localhost:8080, ANTHROPIC_CUSTOM_HEADERS="host: foo.com", CLAUDE_CODE_USE_BEDROCK=1, CLAUDE_CODE_SKIP_BEDROCK_AUTH=1, and ANTHROPIC_BEDROCK_BASE_URL=http://localhost:8080, then sent a prompt.

The requests received by the server now carry host: foo.com — the custom Host header is no longer overridden by the base URL, which is the behavior you expected.

This appears to have been fixed in a recent release (see the changelog). Please upgrade to the latest version.

Closing — reply here if you still see the Host header being overridden on a current version and we'll reopen.

🤖 Generated with Claude Code