fix: rybbit proxy fix

This commit is contained in:
gosangam
2026-06-18 00:51:09 +05:30
parent 84cb273941
commit 1fe10adb1e
2 changed files with 23 additions and 4 deletions
+23
View File
@@ -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" },
});
}
-4
View File
@@ -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`,
},
];
},
};