From 9141b1d854544e8e42d35b0a6119d3e48a2092d0 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 8 Nov 2023 07:37:01 +0100 Subject: Fix metrics of redirects and /health --- src/app.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/app.ts') diff --git a/src/app.ts b/src/app.ts index 7250a62..6843ccd 100644 --- a/src/app.ts +++ b/src/app.ts @@ -145,20 +145,20 @@ export const server = { "http.user_agent": request.headers.get("user-agent"), }, }); - if (pathname === "/health") { - return new Response("OK", { status: 200 }); - } else if ( - config.redirect_other_hostnames && - request.headers.get("host") !== expectedHostURL.host - ) { - return new Response("", { - status: 301, - headers: { - location: new URL(pathname, expectedHostURL).toString(), - }, - }); - } try { + if (pathname === "/health") { + return new Response("OK", { status: 200 }); + } else if ( + config.redirect_other_hostnames && + request.headers.get("host") !== expectedHostURL.host + ) { + return new Response("", { + status: 301, + headers: { + location: new URL(pathname, expectedHostURL).toString(), + }, + }); + } const file = files.get(pathname); if (file && (await file.handle.exists())) { if ( -- cgit 1.4.1