dx route update
This commit is contained in:
parent
72a908134b
commit
a5e6174242
1 changed files with 9 additions and 7 deletions
|
|
@ -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/<anything...>?<query>
|
||||
// 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<any>(p, bearer);
|
||||
return NextResponse.json(json, { status: 200 });
|
||||
} catch (e: any) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue