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

Function getCustomHeaders

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

Source from the content-addressed store, hash-verified

292}
293
294function getCustomHeaders(): Record<string, string> {
295 const customHeaders: Record<string, string> = {}
296 const customHeadersEnv = process.env.ANTHROPIC_CUSTOM_HEADERS
297
298 if (!customHeadersEnv) return customHeaders
299
300 // Split by newlines to support multiple headers
301 const headerStrings = customHeadersEnv.split(/\n|\r\n/)
302
303 for (const headerString of headerStrings) {
304 if (!headerString.trim()) continue
305
306 // Parse header in format "Name: Value" (curl style). Split on first `:`
307 // then trim — avoids regex backtracking on malformed long header lines.
308 const colonIdx = headerString.indexOf(':')
309 if (colonIdx === -1) continue
310 const name = headerString.slice(0, colonIdx).trim()
311 const value = headerString.slice(colonIdx + 1).trim()
312 if (name) {
313 customHeaders[name] = value
314 }
315 }
316
317 return customHeaders
318}
319
320export const CLIENT_REQUEST_ID_HEADER = 'x-client-request-id'
321

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected