mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-20 07:16:46 +00:00
24 lines
558 B
TypeScript
24 lines
558 B
TypeScript
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
import { host } from '../lib/config'
|
|
|
|
export default async (
|
|
req: NextApiRequest,
|
|
res: NextApiResponse
|
|
): Promise<void> => {
|
|
if (req.method !== 'GET') {
|
|
return res.status(405).send({ error: 'method not allowed' })
|
|
}
|
|
|
|
// cache robots.txt for up to 60 seconds
|
|
res.setHeader(
|
|
'Cache-Control',
|
|
'public, s-maxage=60, max-age=60, stale-while-revalidate=60'
|
|
)
|
|
res.setHeader('Content-Type', 'text/plain')
|
|
res.write(`User-agent: *
|
|
Sitemap: ${host}/api/sitemap.xml
|
|
`)
|
|
res.end()
|
|
}
|