Files
nuxt4-deep/server/routes/robots.txt.ts
hyeonggil fc7d3d14cf Add initial Nuxt 4 project setup with essential configurations
- Created .gitignore to exclude build outputs, logs, and environment files.
- Added nuxt.config.ts for project configuration, enabling Tailwind CSS and Pinia modules.
- Initialized package.json with scripts for development and production, and added necessary dependencies.
- Generated pnpm-lock.yaml for dependency management.
- Created README.md with setup instructions and development guidelines.
- Implemented server API examples in server/api/ directory, demonstrating various use cases.
- Added middleware for logging requests and responses.
- Included example Vue components and pages for server API interaction.
- Established basic project structure for Nuxt 4 application development.
2026-04-08 23:59:29 +09:00

35 lines
822 B
TypeScript

/**
* 케이스 8-c: robots.txt
*
* server/routes/ 사용 사례 — /api 접두사 없이 /robots.txt URL로 직접 제공
*
* URL: GET /robots.txt
*/
export default defineEventHandler((event) => {
// 텍스트 Content-Type 지정
setHeader(event, "Content-Type", "text/plain");
setHeader(event, "Cache-Control", "max-age=600");
const baseUrl = "https://example.com";
console.log(event);
// 크롤러별 접근 규칙 설정
return [
"# 모든 크롤러 허용",
"User-agent: *",
"Allow: /",
"",
"# 관리자/내부 경로 차단",
"Disallow: /admin",
"Disallow: /api/",
"Disallow: /_nuxt/",
"",
"# GPTBot (ChatGPT 크롤러) 차단 예시",
"# User-agent: GPTBot",
"# Disallow: /",
"",
`Sitemap: ${baseUrl}/sitemap.xml`,
].join("\n");
});