Skip to content

Commit

Permalink
test embed api
Browse files Browse the repository at this point in the history
  • Loading branch information
ibastawisi committed Jan 30, 2025
1 parent ed06b90 commit 1db8c52
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/app/api/embed/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { NextResponse } from "next/server"
import { generateServerHtml } from "@/editor/utils/generateServerHtml";

export async function POST(request: Request) {
try {
const body = await request.json();
if (!body) {
return NextResponse.json({ error: { title: "Invalid request", subtitle: "Please try again later" } }, { status: 400 })
}
const html = await generateServerHtml(body);
return new Response(html, {
headers: {
"Content-Type": "text/html",
},
});
} catch (error) {
console.error(error);
return NextResponse.json({ error: { title: "Something went wrong", subtitle: "Please try again later" } }, { status: 500 });
}
}

0 comments on commit 1db8c52

Please sign in to comment.