[BUG] Host Header is overriden with Base URL

Open 💬 3 comments Opened Jun 17, 2025 by czgu

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 ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗