all repos — homestead @ 8d44db26fe78dfa824a9f14013bf586608564dd3

Code for my website

Fix metrics of redirects and /health

Alan Pearce
commit

8d44db26fe78dfa824a9f14013bf586608564dd3

parent

31ae15a24fc8f174f5880fd35ec28c6482a898ad

1 file changed, 13 insertions(+), 13 deletions(-)

jump to
M src/app.tssrc/app.ts
@@ -145,20 +145,20 @@ "http.method": request.method,
"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 (