fix: rybbit proxy fix
This commit is contained in:
@@ -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" },
|
||||
});
|
||||
}
|
||||
@@ -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`,
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user