15 lines
401 B
TypeScript
15 lines
401 B
TypeScript
import { BodyData } from "@/src/types";
|
|
import { NextResponse } from "next/server";
|
|
|
|
export function withBody(handler: BodyData) {
|
|
return async (req: Request) => {
|
|
const body = await req.json();
|
|
const { url } = body;
|
|
|
|
if (!url || !url.includes("tokopedia.com")) {
|
|
return NextResponse.json({ error: "URL tidak valid" }, { status: 400 });
|
|
}
|
|
return handler(req, body);
|
|
};
|
|
}
|