diff --git a/api/block-bots.js b/api/block-bots.js deleted file mode 100644 index bbaeca79..00000000 --- a/api/block-bots.js +++ /dev/null @@ -1,53 +0,0 @@ -import { getStore } from '@netlify/blobs' -import { DateTime } from 'luxon' - -const botUas = [ - 'AdsBot-Google', - 'Amazonbot', - 'anthropic-ai', - 'Applebot', - 'AwarioRssBot', - 'AwarioSmartBot', - 'Bytespider', - 'CCBot', - 'ChatGPT', - 'ChatGPT-User', - 'Claude-Web', - 'ClaudeBot', - 'cohere-ai', - 'DataForSeoBot', - 'Diffbot', - 'FacebookBot', - 'FacebookBot', - 'Google-Extended', - 'GPTBot', - 'ImagesiftBot', - 'magpie-crawler', - 'omgili', - 'Omgilibot', - 'peer39_crawler', - 'PerplexityBot', - 'YouBot' -] - -export default async (request, context) => { - const ua = request.headers.get('user-agent'); - const bots = getStore('bots') - let isBot = false - - botUas.forEach(u => { - if (ua.toLowerCase().includes(u.toLowerCase())) { - isBot = true - } - }) - - if (isBot) await bots.set(ua, DateTime.now()) - - const response = isBot ? new Response(null, { status: 401 }) : await context.next(); - - return response -}; - -export const config = { - path: '/*', -} \ No newline at end of file