changes
This commit is contained in:
@@ -8,13 +8,11 @@ interface PagesContext {
|
|||||||
export function onRequest(context: PagesContext): Response | Promise<Response> {
|
export function onRequest(context: PagesContext): Response | Promise<Response> {
|
||||||
const { request } = context;
|
const { request } = context;
|
||||||
const userAgent = request.headers.get("user-agent") ?? "";
|
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 (
|
if (request.method === "GET" && isCommandLineClient) {
|
||||||
request.method === "GET" &&
|
|
||||||
pathname === "/" &&
|
|
||||||
/^curl(?:\/|$)/i.test(userAgent)
|
|
||||||
) {
|
|
||||||
return curlResponse();
|
return curlResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ export default function () {
|
|||||||
headers: {
|
headers: {
|
||||||
"Cache-Control": "no-cache, no-store, must-revalidate",
|
"Cache-Control": "no-cache, no-store, must-revalidate",
|
||||||
"Content-Type": "text/plain; charset=utf-8",
|
"Content-Type": "text/plain; charset=utf-8",
|
||||||
Vary: "User-Agent",
|
Vary: "User-Agent, Accept",
|
||||||
"X-Content-Type-Options": "nosniff",
|
"X-Content-Type-Options": "nosniff",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user