40 lines
880 B
TypeScript
40 lines
880 B
TypeScript
import { NextResponse } from "next/server"
|
|
import type { NextRequest } from "next/server"
|
|
import {
|
|
PRODUCTION_HOST,
|
|
PRODUCTION_WEBSITE,
|
|
isProductionHost,
|
|
normalizeHost,
|
|
} from "@/lib/seo-config"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
const productionRobots = `User-agent: *
|
|
Allow: /
|
|
Disallow: /api/
|
|
Disallow: /admin/
|
|
Disallow: /_next/
|
|
Disallow: /test-page/
|
|
Disallow: /manuals/dashboard/
|
|
|
|
Sitemap: ${PRODUCTION_WEBSITE}/sitemap.xml
|
|
Host: ${PRODUCTION_HOST}
|
|
`
|
|
|
|
const previewRobots = `User-agent: *
|
|
Disallow: /
|
|
|
|
Sitemap: ${PRODUCTION_WEBSITE}/sitemap.xml
|
|
Host: ${PRODUCTION_HOST}
|
|
`
|
|
|
|
export function GET(request: NextRequest) {
|
|
const host = normalizeHost(request.headers.get("host"))
|
|
const body = isProductionHost(host) ? productionRobots : previewRobots
|
|
|
|
return new NextResponse(body, {
|
|
headers: {
|
|
"Content-Type": "text/plain; charset=utf-8",
|
|
},
|
|
})
|
|
}
|