MCPcopy Create free account
hub / github.com/freecodexyz/free-code / getCustomHeaders

Function getCustomHeaders

src/services/api/client.ts:353–377  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

351}
352
353function getCustomHeaders(): Record<string, string> {
354 const customHeaders: Record<string, string> = {}
355 const customHeadersEnv = process.env.ANTHROPIC_CUSTOM_HEADERS
356
357 if (!customHeadersEnv) return customHeaders
358
359 // Split by newlines to support multiple headers
360 const headerStrings = customHeadersEnv.split(/\n|\r\n/)
361
362 for (const headerString of headerStrings) {
363 if (!headerString.trim()) continue
364
365 // Parse header in format "Name: Value" (curl style). Split on first `:`
366 // then trim — avoids regex backtracking on malformed long header lines.
367 const colonIdx = headerString.indexOf(':')
368 if (colonIdx === -1) continue
369 const name = headerString.slice(0, colonIdx).trim()
370 const value = headerString.slice(colonIdx + 1).trim()
371 if (name) {
372 customHeaders[name] = value
373 }
374 }
375
376 return customHeaders
377}
378
379export const CLIENT_REQUEST_ID_HEADER = 'x-client-request-id'
380

Callers 1

getAnthropicClientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected