From 623d433f529f434e381c9ff8f879e2ca95e10163 Mon Sep 17 00:00:00 2001 From: Kat <49850194+datkat21@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:01:55 -0600 Subject: [PATCH] add slash --- handlers/handling.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/handlers/handling.ts b/handlers/handling.ts index c3a1121..4f60dd1 100644 --- a/handlers/handling.ts +++ b/handlers/handling.ts @@ -87,7 +87,15 @@ export function fileOnlyReqHandler( let urlPath = url.pathname.substring(prefix.length); // default handlers built into the program - if (urlPath.endsWith("/") || urlPath === "") { + if (urlPath === "") { + // redirect to / + return new Response("Redirect", { + status: 301, + statusText: "Moved", + headers: { Location: prefix + "/" }, + }); + } + if (urlPath.endsWith("/")) { urlPath = "/index.html"; }