co2 galvo owner test
This commit is contained in:
parent
f61029a8ca
commit
2e08d68b24
3 changed files with 80 additions and 21 deletions
23
app/api/dx/[...path]/route.ts
Normal file
23
app/api/dx/[...path]/route.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// app/api/dx/[...path]/route.ts
|
||||
import { NextResponse } from "next/server";
|
||||
import { requireBearer } from "@/app/api/_lib/auth";
|
||||
|
||||
const BASE = (process.env.DIRECTUS_URL || "").replace(/\/$/, "");
|
||||
|
||||
export async function GET(req: Request, { params }: { params: { path: string[] } }) {
|
||||
const bearer = requireBearer(req);
|
||||
const search = new URL(req.url).search || "";
|
||||
const path = params.path.join("/");
|
||||
const url = `${BASE}/${path}${search}`;
|
||||
|
||||
const res = await fetch(url, {
|
||||
headers: { Accept: "application/json", Authorization: `Bearer ${bearer}` },
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
const body = await res.text();
|
||||
return new NextResponse(body, {
|
||||
status: res.status,
|
||||
headers: { "content-type": res.headers.get("content-type") || "application/json" },
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue