export default { async fetch(request, env) { const url = new URL(request.url); if (url.pathname === "/" || url.pathname === "/index.html") { return new Response(HTML, { headers: { "Content-Type": "text/html;charset=UTF-8" } }); } if (url.pathname === "/api/products") { try { const res = await fetch(env.BASE44_FUNCTION_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({}), }); const data = await res.json(); return Response.json(data, { headers: { "Access-Control-Allow-Origin": "*" } }); } catch (e) { return Response.json({ error: e.message }, { status: 500 }); } } return new Response("Not found", { status: 404 }); }, }; const HTML = `