export async function onRequest(context) { const url = new URL(context.request.url); // Ambil semua string setelah tanda tanya (?) // Misal: /horizon?=SGVsbG8= -> isinya "?=SGVsbG8=" let fullQuery = url.search; if (!fullQuery || fullQuery.length < 3) { return new Response("Mana datanya, Bro? Kosong! 😭", { status: 400 }); } try { // 1. Bersihin query string // Kita buang "?=" di depan let base64Part = fullQuery.substring(2); // 2. Buang sampah kosmetik (.png, .js, dll) di paling belakang base64Part = base64Part.replace(/\.(png|jpg|js|svg|webp)$/i, ""); // 3. Decode Base64 // Pake decodeURIComponent buat jaga-jaga kalau browser ngerubah karakter const decodedHtml = atob(decodeURIComponent(base64Part)); const svg = `
${decodedHtml}
`; return new Response(svg, { headers: { "Content-Type": "image/svg+xml", "Cache-Control": "no-cache", "Access-Control-Allow-Origin": "*" }, }); } catch (e) { return new Response("Waduh, Base64 lu hancur/salah format: " + e.message, { status: 500 }); } }