This commit is contained in:
15
src/routes/robots.txt/+server.ts
Normal file
15
src/routes/robots.txt/+server.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { SITE_ORIGIN } from '$lib/seo';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = ({ url }) => {
|
||||
const production = url.hostname === new URL(SITE_ORIGIN).hostname;
|
||||
const body = production
|
||||
? `User-agent: *\nAllow: /\nSitemap: ${SITE_ORIGIN}/sitemap.xml\n`
|
||||
: 'User-agent: *\nDisallow: /\n';
|
||||
return new Response(body, {
|
||||
headers: {
|
||||
'content-type': 'text/plain; charset=utf-8',
|
||||
'cache-control': 'public, max-age=3600'
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user