v1.1: Add CIDR subnet filtering and Agent filter in Devices page

This commit is contained in:
ypratama committed 2026-08-27 12:02:01 +07:00
commit 966058e2fe
422 files changed
+54656

No files matched your search

@@ -0,0 +1,48 @@
import { NextRequest, NextResponse } from "next/server";
import { cookies } from "next/headers";
const BACKEND_URL = process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:3011";
export async function POST(req: NextRequest) {
try {
const cookieStore = await cookies();
const token = cookieStore.get("token")?.value;
// Menerima JSON dari frontend (bukan multipart)
const body = await req.json();
const headers = new Headers();
headers.set("Content-Type", "application/json");
if (token) {
headers.set("Cookie", `token=${token}`);
}
req.headers.forEach((value, name) => {
if (name.toLowerCase().startsWith("x-")) {
headers.set(name, value);
}
});
const destinationUrl = `${BACKEND_URL}/api/auth/admin/create-external-user`;
const response = await fetch(destinationUrl, {
method: "POST",
headers,
body: JSON.stringify(body),
cache: "no-store",
});
const responseBuffer = await response.arrayBuffer();
return new NextResponse(responseBuffer, {
status: response.status,
headers: {
"Content-Type": response.headers.get("content-type") || "application/json",
},
});
} catch (err: any) {
console.error("[Create External User Proxy] Error:", err.message);
return NextResponse.json(
{ ok: false, error: "Failed to connect to the server." },
{ status: 502 }
);
}
}