diff --git a/app/api/track/route.ts b/app/api/track/route.ts new file mode 100644 index 00000000..2df79411 --- /dev/null +++ b/app/api/track/route.ts @@ -0,0 +1,23 @@ +// 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" }, + }); +} \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index aea9f157..b3af0ee0 100644 --- a/next.config.ts +++ b/next.config.ts @@ -16,10 +16,6 @@ const nextConfig: NextConfig = { source: "/api/script.js", destination: `${process.env.NEXT_PUBLIC_RYBBIT_HOST}/api/script.js`, }, - { - source: "/api/track", - destination: `${process.env.NEXT_PUBLIC_RYBBIT_HOST}/api/track`, - }, ]; }, };