import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

// Blocked SEO analysis tools and web scrapers
const BLOCKED_BOTS = /AhrefsBot|SemrushBot|MJ12bot|DotBot|Rogerbot|SEOkicks|SEBot-WA|SERankingBacklinksBot|SerpstatBot|SISTRIX|DataForSeoBot|BLEXBot|Screaming Frog|UbersuggestBot|SpyFu|SimilarWebBot|Netcraft|zoominfobot|serendeputy|PetalBot|Sogou|Baiduspider|YandexBot/i;

export function proxy(request: NextRequest) {
  // Block known SEO scrapers and analysis bots
  const userAgent = request.headers.get('user-agent') || '';
  if (BLOCKED_BOTS.test(userAgent)) {
    return new NextResponse('Forbidden', { status: 403 });
  }

  return NextResponse.next();
}
