Skip to content

Commit

Permalink
Fixed robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Jan 2, 2025
1 parent 4dfd341 commit 2679028
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions functions/robots.txt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { StatusCodes } from 'http-status-codes';
import { ReasonPhrases, 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);
return new Response('User-agent: *\nDisallow: /', {
status: StatusCodes.OK,
statusText: ReasonPhrases.OK,
headers: {
'access-control-allow-origin': '*',
'content-type': 'text/plain; charset=utf-8',
},
});
} catch {
return new Response(null, {
status: StatusCodes.OK,
statusText: ReasonPhrases.OK,
headers: {
'access-control-allow-origin': '*',
'content-type': 'text/plain; charset=utf-8',
},
});
}
}

0 comments on commit 2679028

Please sign in to comment.