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>
This commit is contained in:
co-authored by
Cursor
parent
cd2f9dfc9d
commit
66e604c426
@@ -0,0 +1,33 @@
|
||||
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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user