export default { async fetch(request, env) { const url = new URL(request.url); // --- 1. HANDLE PASSWORD VERIFICATION (POST REQUEST) --- if (request.method === "POST" && url.pathname === "/verify") { try { const body = await request.json(); const { password } = body; // Check if the entered password matches the Admin or User password if (password === env.ADMIN_PASSWORD) { return Response.json({ success: true, token: env.ADMIN_MACRO_SECRET }); } else if (password === env.USER_PASSWORD) { return Response.json({ success: true, token: env.USER_MACRO_TOKEN }); } else { return Response.json({ success: false, error: "Invalid password" }, { status: 401 }); } } catch (err) { return Response.json({ success: false, error: "Bad request" }, { status: 400 }); } } // --- 2. SERVE THE HTML JUMP PAGE (GET REQUEST) --- const html = ` System Check

System Check 🚀

If the app is installed, it will open automatically. If nothing happens, choose an option below.

Open App
`; return new Response(html, { headers: { "Content-Type": "text/html;charset=UTF-8" } }); } };