import type { APIRoute } from 'astro'; // 샘플: 검색·AI 크롤러 전면 차단. 프로덕션(PUBLIC_INDEXABLE=true): 전면 허용 + AI 크롤러 명시 허용. // 링크 미리보기 봇은 샘플에서도 허용한다. 막으면 카카오톡·슬랙·iMessage 에 주소를 붙였을 때 제목·이미지가 안 나온다. // 이 봇들은 붙여 넣은 주소 한 장만 읽고 색인하지 않는다. noindex 메타·X-Robots-Tag 는 그대로다. const PREVIEW_BOTS = ['kakaotalk-scrap', 'facebookexternalhit', 'Facebot', 'Twitterbot', 'Slackbot', 'Slackbot-LinkExpanding', 'Discordbot', 'TelegramBot', 'WhatsApp', 'LinkedInBot']; const AI_BOTS = ['GPTBot', 'OAI-SearchBot', 'ChatGPT-User', 'PerplexityBot', 'ClaudeBot', 'Claude-SearchBot', 'Google-Extended', 'Applebot-Extended', 'Bingbot', 'Yeti', 'Googlebot']; export const GET: APIRoute = ({ site }) => { const indexable = import.meta.env.PUBLIC_INDEXABLE === 'true'; const body = indexable ? [...AI_BOTS.map((b) => `User-agent: ${b}\nAllow: /`), 'User-agent: *\nAllow: /', `Sitemap: ${site}sitemap.xml`].join('\n\n') + '\n' : [`# 샘플 사이트. 색인 금지. 링크 미리보기만 허용.`, ...PREVIEW_BOTS.map((b) => `User-agent: ${b}\nAllow: /`), 'User-agent: *\nDisallow: /'].join('\n\n') + '\n'; return new Response(body, { headers: { 'Content-Type': 'text/plain; charset=utf-8' } }); };