Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
19 lines
1.0 KiB
TypeScript
19 lines
1.0 KiB
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
import { callMobileApi } from "@/app/lib/server/mobileApi";
|
|
import { getToken } from "@/app/lib/server/session";
|
|
import { badRequest, errorResponse, unauthorized } from "@/app/lib/server/apiRoute";
|
|
|
|
// Read-only proxy for /api/admin/audit-log[/<id>]; mobile-api owns the BO_AUDIT_LOG guard. Audit events are never writable from the portal, so GET is the only method.
|
|
type Ctx = { params: Promise<{ path?: string[] }> };
|
|
|
|
export async function GET(req: NextRequest, { params }: Ctx) {
|
|
const token = await getToken();
|
|
if (!token) return unauthorized();
|
|
const { path = [] } = await params;
|
|
if (path.some((s) => s === "." || s === "..")) return badRequest("Invalid path.");
|
|
const target = `/api/admin/audit-log${path.map(encodeURIComponent).map((s) => `/${s}`).join("")}${new URL(req.url).search}`;
|
|
const result = await callMobileApi<unknown>(target, { token });
|
|
if (!result.ok) return errorResponse(result);
|
|
return NextResponse.json(result.data);
|
|
}
|