Add the FarrokhWin Next.js site for Meshkee hosting.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { meshkeeApiBase, websiteDomain } from "@/lib/config";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const body = (await request.json()) as {
|
||||
entityType?: string;
|
||||
entityId?: string;
|
||||
authorName?: string;
|
||||
authorEmail?: string;
|
||||
text?: string;
|
||||
};
|
||||
|
||||
if (!body.entityType?.trim() || !body.entityId?.trim() || !body.authorName?.trim() || !body.text?.trim()) {
|
||||
return NextResponse.json({ message: "نام و متن نظر الزامی است." }, { status: 400 });
|
||||
}
|
||||
|
||||
const auth = request.headers.get("authorization");
|
||||
const headers: Record<string, string> = { "Content-Type": "application/json" };
|
||||
if (auth) headers.Authorization = auth;
|
||||
|
||||
const response = await fetch(`${meshkeeApiBase}/tenants/${encodeURIComponent(websiteDomain)}/comments`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
entityType: body.entityType.trim(),
|
||||
entityId: body.entityId.trim(),
|
||||
authorName: body.authorName.trim(),
|
||||
authorEmail: body.authorEmail?.trim() || undefined,
|
||||
text: body.text.trim(),
|
||||
}),
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
const data = await response.json().catch(() => ({}));
|
||||
return NextResponse.json(data, { status: response.status });
|
||||
}
|
||||
Reference in New Issue
Block a user