(request: Request)
| 70 | * See https://vercel.com/docs/edge-network/headers/request-headers |
| 71 | */ |
| 72 | const resolveClientIp = (request: Request): string | null => { |
| 73 | const forwardedFor = request.headers.get("x-forwarded-for"); |
| 74 | if (forwardedFor) { |
| 75 | const first = forwardedFor.split(",")[0]?.trim(); |
| 76 | if (first) { |
| 77 | return first; |
| 78 | } |
| 79 | } |
| 80 | return request.headers.get("x-vercel-forwarded-for"); |
| 81 | }; |
| 82 | |
| 83 | const checkRateLimit = (clientIp: string): boolean => { |
| 84 | const now = Date.now(); |