(req: NextRequest)
| 226 | } |
| 227 | |
| 228 | export 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 | |
| 242 | export function hashClientIp( |
| 243 | clientIp: string | undefined, |
no test coverage detected