MCPcopy
hub / github.com/CodebuffAI/codebuff / extractClientIp

Function extractClientIp

web/src/server/free-mode-country.ts:228–240  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

226}
227
228export function extractClientIp(req: NextRequest): string | undefined {
229 const cfConnectingIp = req.headers.get('cf-connecting-ip')?.trim()
230 if (cfConnectingIp) return cfConnectingIp
231
232 const realIp = req.headers.get('x-real-ip')?.trim()
233 if (realIp) return realIp
234
235 const forwardedFor = req.headers.get('x-forwarded-for')
236 if (forwardedFor) {
237 return forwardedFor.split(',')[0].trim()
238 }
239 return undefined
240}
241
242export function hashClientIp(
243 clientIp: string | undefined,

Callers 2

getFreeModeCountryAccessFunction · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected