Skip to content

Commit 3b25404

Browse files
crystalinclaude
andcommitted
fix(bedrock): use blacklist approach for header filtering
- Blacklist only: authorization, host, content-length - Pass through all other headers (anthropic-beta, user-agent, etc.) - Preserves important client headers while removing proxy-specific ones - More maintainable than whitelist approach 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 02c024f commit 3b25404

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

services/proxy/src/services/BedrockApiClient.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,21 @@ export class BedrockApiClient {
4141
const url = `https://bedrock-runtime.${this.config.region}.amazonaws.com/model/${bedrockModelId}/invoke${streamSuffix}`
4242

4343
// Prepare Bedrock-specific headers
44-
// Note: Bedrock uses x-api-key, not Authorization header
44+
// Blacklist headers that should not be forwarded to Bedrock
45+
const blacklistedHeaders = ['authorization', 'host', 'content-length']
46+
const clientHeaders = request.createHeaders({})
47+
48+
// Filter out blacklisted headers
49+
const filteredHeaders: Record<string, string> = {}
50+
for (const [key, value] of Object.entries(clientHeaders)) {
51+
if (!blacklistedHeaders.includes(key.toLowerCase())) {
52+
filteredHeaders[key] = value
53+
}
54+
}
55+
56+
// Add Bedrock authentication
4557
const headers = {
46-
'Content-Type': 'application/json',
58+
...filteredHeaders,
4759
...authHeaders, // Contains x-api-key
4860
}
4961

0 commit comments

Comments
 (0)