feat: integrate Cloudflare Turnstile for enhanced security in sign-up and email verification processes. Implement rate limiting for sign-up attempts and add Turnstile validation to prevent abuse. Update environment configuration to support Turnstile keys and enhance user experience with improved error handling and feedback.
83e82db | import type { Context as HonoContext } from "hono"; | |
| export function getClientIp(context: HonoContext): string | undefined { | |
| const headers = context.req.raw.headers; | |
| const cfIp = headers.get("cf-connecting-ip"); | |
| if (cfIp) return cfIp.trim(); | |
| const forwarded = headers.get("x-forwarded-for"); | |
| if (forwarded) { | |
| const firstIp = forwarded.split(",")[0]?.trim(); | |
| if (firstIp) return firstIp; | |
| } | |
| const realIp = headers.get("x-real-ip"); | |
| if (realIp) return realIp.trim(); | |
| return undefined; | |
| } | |