diff --git a/app/api/dx/[...path]/route.ts b/app/api/dx/[...path]/route.ts index 91530049..43eb5d02 100644 --- a/app/api/dx/[...path]/route.ts +++ b/app/api/dx/[...path]/route.ts @@ -4,17 +4,19 @@ import { dxGET } from "@/lib/directus"; import { requireBearer } from "@/app/api/_lib/auth"; export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; // proxy to Directus; never static // GET /api/dx/? // Proxies to Directus using the user's ma_at, no caching. -export async function GET( - req: Request, - { params }: { params: { path: string[] } } -) { +export async function GET(req: Request, context: any) { try { - const bearer = requireBearer(req); // <-- pulls ma_at from Cookie - const search = new URL(req.url).search; // keep original query - const p = `/${(params.path || []).join("/")}${search || ""}`; + const bearer = requireBearer(req); // ← pulls ma_at from Cookie + const search = new URL(req.url).search || ""; + const params = (context?.params ?? {}) as { path?: string[] }; + + const pathParts = Array.isArray(params.path) ? params.path : []; + const p = `/${pathParts.join("/")}${search}`; + const json = await dxGET(p, bearer); return NextResponse.json(json, { status: 200 }); } catch (e: any) {