fix: rybbit proxy fix
This commit is contained in:
@@ -1,18 +1,17 @@
|
|||||||
// app/api/track/route.ts
|
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
const ip =
|
const ip =
|
||||||
req.headers.get("x-forwarded-for")?.split(",")[0].trim() ??
|
req.headers.get("x-forwarded-for")?.split(",")[0].trim() ??
|
||||||
req.headers.get("x-real-ip") ??
|
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
|
||||||
|
|
||||||
const res = await fetch(`${process.env.NEXT_PUBLIC_RYBBIT_HOST}/api/track`, {
|
const res = await fetch(`${process.env.NEXT_PUBLIC_RYBBIT_HOST}/api/track`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
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(),
|
body: await req.text(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user