Files
spsays-training/app/api/track/route.ts
T
2026-06-18 00:51:09 +05:30

23 lines
695 B
TypeScript

// app/api/track/route.ts
export async function POST(req: Request) {
const ip =
req.headers.get("x-forwarded-for")?.split(",")[0].trim() ??
req.headers.get("x-real-ip") ??
"";
const res = await fetch(`${process.env.NEXT_PUBLIC_RYBBIT_HOST}/api/track`, {
method: "POST",
headers: {
"content-type": req.headers.get("content-type") ?? "application/json",
"user-agent": req.headers.get("user-agent") ?? "",
"x-forwarded-for": ip,
"x-real-ip": ip,
},
body: await req.text(),
});
return new Response(await res.text(), {
status: res.status,
headers: { "content-type": res.headers.get("content-type") ?? "application/json" },
});
}