From 4dfd341e1948e6c4ff6ebfbe26aeddeea86341db Mon Sep 17 00:00:00 2001 From: James Prevett Date: Thu, 2 Jan 2025 17:07:28 -0600 Subject: [PATCH] Add robots.txt --- functions/robots.txt.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 functions/robots.txt.ts diff --git a/functions/robots.txt.ts b/functions/robots.txt.ts new file mode 100644 index 0000000..f3511ff --- /dev/null +++ b/functions/robots.txt.ts @@ -0,0 +1,12 @@ +import { StatusCodes } from 'http-status-codes'; +import type { RequestContext } from '../src/backend/context'; +import { error, response } from '../src/backend/utils'; + +export async function onRequest({ env }: RequestContext) { + try { + return response(StatusCodes.OK, 'User-agent: *\nDisallow: /', false); + } catch (e: any) { + console.error(e); + return error(StatusCodes.INTERNAL_SERVER_ERROR, env.DEBUG && e?.message); + } +}