Skip to content

Commit 2679028

Browse files
committed
Fixed robots.txt
1 parent 4dfd341 commit 2679028

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

functions/robots.txt.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
import { StatusCodes } from 'http-status-codes';
1+
import { ReasonPhrases, StatusCodes } from 'http-status-codes';
22
import type { RequestContext } from '../src/backend/context';
3-
import { error, response } from '../src/backend/utils';
43

54
export async function onRequest({ env }: RequestContext) {
65
try {
7-
return response(StatusCodes.OK, 'User-agent: *\nDisallow: /', false);
8-
} catch (e: any) {
9-
console.error(e);
10-
return error(StatusCodes.INTERNAL_SERVER_ERROR, env.DEBUG && e?.message);
6+
return new Response('User-agent: *\nDisallow: /', {
7+
status: StatusCodes.OK,
8+
statusText: ReasonPhrases.OK,
9+
headers: {
10+
'access-control-allow-origin': '*',
11+
'content-type': 'text/plain; charset=utf-8',
12+
},
13+
});
14+
} catch {
15+
return new Response(null, {
16+
status: StatusCodes.OK,
17+
statusText: ReasonPhrases.OK,
18+
headers: {
19+
'access-control-allow-origin': '*',
20+
'content-type': 'text/plain; charset=utf-8',
21+
},
22+
});
1123
}
1224
}

0 commit comments

Comments
 (0)