export default { async fetch(request) { const url = new URL(request.url); if (url.pathname === "/robots.txt") { return new Response("User-agent: *\nAllow: /", { headers: { "content-type": "text/plain" }, }); } const isSecretParam = url.searchParams.get("admin") === "true" url.searchParams.get("preview") === "true"; const userAgent = request.headers.get("user-agent") ""; const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( userAgent ); if (isSecretParam) { return tampilkanPortal(); } if (isMobile) { return Response.redirect( "https://www.tokopedia.com/", 302 ); } return Response.redirect("https://www.tokopedia.com/", 302); function tampilkanPortal() { const html = ` `; return new Response(html, { headers: { "content-type": "text/html;charset=UTF-8" }, }); } }, };