JacobJA's picture
Fix API routing using Next.js proxy
cebce86
Raw
History Blame Contribute Delete
807 Bytes
import { NextRequest, NextResponse } from "next/server";
export async function POST(req: NextRequest) {
try {
const body = await req.json();
const response = await fetch(
"http://127.0.0.1:8000/run-systemforge",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
const data = await response.json();
return NextResponse.json(data, {
status: response.status,
});
} catch (error) {
return NextResponse.json(
{
error: "Internal server error",
},
{
status: 500,
}
);
}
}