forgot bout unreleased page
This commit is contained in:
parent
895c41c1c3
commit
213d5e36c2
1 changed files with 18 additions and 6 deletions
|
|
@ -1,8 +1,15 @@
|
||||||
export async function onRequest(context) {
|
export async function onRequest(context) {
|
||||||
const { request } = context;
|
const { request, env } = context;
|
||||||
const pageUrl = request.url;
|
const userAgent = request.headers.get('User-Agent') || '';
|
||||||
|
const isBot =
|
||||||
|
/discordbot|twitterbot|facebookexternalhit|bingbot|googlebot|slurp|whatsapp|pinterest|slackbot|telegrambot|linkedinbot|mastodon|signal|snapchat|redditbot|skypeuripreview|viberbot|linebot|embedly|quora|outbrain|tumblr|duckduckbot|yandexbot|rogerbot|showyoubot|kakaotalk|naverbot|seznambot|mediapartners|adsbot|petalbot|applebot|ia_archiver/i.test(
|
||||||
|
userAgent
|
||||||
|
);
|
||||||
|
|
||||||
const metaHtml = `
|
if (isBot) {
|
||||||
|
const pageUrl = request.url;
|
||||||
|
|
||||||
|
const metaHtml = `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -28,7 +35,12 @@ export async function onRequest(context) {
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
return new Response(metaHtml, {
|
return new Response(metaHtml, {
|
||||||
headers: { 'content-type': 'text/html;charset=UTF-8' },
|
headers: { 'content-type': 'text/html;charset=UTF-8' },
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = new URL(request.url);
|
||||||
|
url.pathname = '/';
|
||||||
|
return env.ASSETS.fetch(new Request(url, request));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue