Dev console

This commit is contained in:
Jack Mechem 2026-05-21 16:35:34 -07:00
parent 882ff7696a
commit 130bed1d1f
Signed by: jackmechem
SSH key fingerprint: SHA256:GjIjMAC33pzYOe+hWcX5uvgnPrVFAXSrquvt84AOJbU
5 changed files with 4790 additions and 60 deletions

View file

@ -0,0 +1,33 @@
import { NextRequest, NextResponse } from "next/server";
export async function POST(req: NextRequest) {
const token = req.cookies.get("token")?.value;
if (!token) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const { method, url, body } = (await req.json()) as {
method: string;
url: string;
body?: unknown;
};
const targetUrl = url.startsWith("http")
? url
: `http://localhost:3001${url.startsWith("/") ? url : `/${url}`}`;
const res = await fetch(targetUrl, {
method,
headers: {
Authorization: `Bearer ${token}`,
...(body !== undefined ? { "Content-Type": "application/json" } : {}),
},
body: body !== undefined ? JSON.stringify(body) : undefined,
});
const text = await res.text();
return new NextResponse(text, {
status: res.status,
headers: { "Content-Type": res.headers.get("Content-Type") ?? "text/plain" },
});
}