File size: 898 Bytes
6fffa8d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import { NextRequest, NextResponse } from "next/server";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function POST(request: NextRequest) {
const backendUrl = process.env.VENICE_BACKEND_URL;
if (!backendUrl) {
return NextResponse.json({ detail: "VENICE_BACKEND_URL is not configured" }, { status: 500 });
}
const response = await fetch(`${backendUrl.replace(/\/$/, "")}/api/generate-node`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: await request.text(),
cache: "no-store",
});
const payload = await response.json();
if (payload?.imageUrl) {
const filename = String(payload.imageUrl).split("/").pop();
if (filename) {
payload.imageUrl = `/api/outputs/${encodeURIComponent(filename)}`;
}
}
return NextResponse.json(payload, { status: response.status });
}
|