export async function POST(req: Request) { const ip = req.headers.get("x-forwarded-for")?.split(",")[0].trim() ?? req.headers.get("x-real-ip") ?? ""; const headers = new Headers(req.headers); headers.set("x-forwarded-for", ip); headers.set("x-real-ip", ip); headers.delete("host"); // avoid sending your app's Host to the Rybbit backend console.log("XFF:", req.headers.get("x-forwarded-for")); console.log("XRI:", req.headers.get("x-real-ip")); console.log("resolved ip:", ip); const res = await fetch(`${process.env.NEXT_PUBLIC_RYBBIT_HOST}/api/track`, { method: "POST", headers, body: await req.text(), }); return new Response(await res.text(), { status: res.status, headers: { "content-type": res.headers.get("content-type") ?? "application/json" }, }); }