changes
This commit is contained in:
@@ -8,13 +8,11 @@ interface PagesContext {
|
||||
export function onRequest(context: PagesContext): Response | Promise<Response> {
|
||||
const { request } = context;
|
||||
const userAgent = request.headers.get("user-agent") ?? "";
|
||||
const pathname = new URL(request.url).pathname;
|
||||
const accept = request.headers.get("accept") ?? "";
|
||||
const isCommandLineClient =
|
||||
/^curl(?:\/|$)/i.test(userAgent) || accept.trim() === "*/*";
|
||||
|
||||
if (
|
||||
request.method === "GET" &&
|
||||
pathname === "/" &&
|
||||
/^curl(?:\/|$)/i.test(userAgent)
|
||||
) {
|
||||
if (request.method === "GET" && isCommandLineClient) {
|
||||
return curlResponse();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user