MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / extractApiKeyFromHeader

Function extractApiKeyFromHeader

web/src/util/auth.ts:27–41  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

25 * Extract api key from x-codebuff-api-key header or authorization header
26 */
27export function extractApiKeyFromHeader(req: NextRequest): string | undefined {
28 const token = req.headers.get('x-codebuff-api-key')
29 if (typeof token === 'string' && token) {
30 return token
31 }
32
33 const authorization = req.headers.get('Authorization')
34 if (!authorization) {
35 return undefined
36 }
37 if (!authorization.startsWith('Bearer ')) {
38 return undefined
39 }
40 return authorization.slice('Bearer '.length)
41}

Callers 12

postLogoutFunction · 0.90
PATCHFunction · 0.90
GETFunction · 0.90
GETFunction · 0.90
requireUserFromApiKeyFunction · 0.90
resolveUserFunction · 0.90
postChatCompletionsFunction · 0.90
getMeFunction · 0.90
postUsageFunction · 0.90
postAgentRunsFunction · 0.90
postAgentRunsStepsFunction · 0.90
POSTFunction · 0.90

Calls 1

getMethod · 0.65

Tested by

no test coverage detected