From f9b4f8dc9b3e918d577bf61763e3b9cf1f0a7891 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 1 Apr 2024 19:53:58 +0200 Subject: Redirect existing index.html files --- src/app.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/app.ts b/src/app.ts index 1b8bcf7..f41d6f2 100644 --- a/src/app.ts +++ b/src/app.ts @@ -214,6 +214,17 @@ export const server = { status: status, headers: { location: newpath }, }); + } else if (files.has(pathname.replace(/index.html$/, ""))) { + newpath = pathname.replace(/index.html$/, ""); + metrics.requests.inc({ + method: request.method, + path: newpath, + status_code: (status = 302), + }); + return new Response("", { + status: status, + headers: { location: newpath }, + }); } metrics.requests.inc({ method: request.method, -- cgit 1.4.1