Files
Alireza HassaniandCursor 66e604c426 Connect the storefront to Meshkee catalog, blogs, and static image slots.
Wire homepage specials, product/blog pages, instant search, and the customer portal so the live pharmacy site can be managed from the dashboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-19 23:51:41 +03:30

34 lines
1.1 KiB
TypeScript

import { customerPortalUrl, meshkeeApiBase } from "@/lib/config";
import { getBusinessId } from "@/lib/meshkee";
export async function POST(request: Request) {
const token = request.headers.get("authorization");
if (!token) {
return Response.json({ error: "login_required", redirect: customerPortalUrl }, { status: 401 });
}
const businessId = await getBusinessId();
if (!businessId) {
return Response.json({ error: "tenant_missing" }, { status: 500 });
}
const body = await request.json();
try {
const response = await fetch(`${meshkeeApiBase}/businesses/${encodeURIComponent(businessId)}/cart/items`, {
method: "POST",
headers: {
Authorization: token,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
const text = await response.text();
return new Response(text, {
status: response.status,
headers: { "Content-Type": response.headers.get("content-type") ?? "application/json" },
});
} catch {
return Response.json({ error: "cart_failed" }, { status: 502 });
}
}