From c2a17d3d69949ab050a9a496427753d188fea1ae Mon Sep 17 00:00:00 2001 From: d9k Date: Fri, 29 Dec 2023 18:29:56 +0500 Subject: [PATCH] #292 serve build: fix log on return 404 --- lib/middleware/serveStatic.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/middleware/serveStatic.ts b/lib/middleware/serveStatic.ts index 0db276f9..596cd22c 100644 --- a/lib/middleware/serveStatic.ts +++ b/lib/middleware/serveStatic.ts @@ -56,6 +56,17 @@ export const serveStatic = (options: ServeStaticOptions = { root: "" }) => { return; } catch (_error) { + + + if (path.match("\.map$")) { + log.debug(`Static file: ${path} does not exist, returning 404`); + + return new Response( + null, + { status: 404 }, + ); + } + /** * This is so we can just continue the request if the above fetch fails, * since the static asset might not exist, and we want to avoid Deno APIs @@ -65,13 +76,6 @@ export const serveStatic = (options: ServeStaticOptions = { root: "" }) => { */ log.debug(`Static file: ${path} does not exist, continuing`); - if (path.match("\.map$")) { - return new Response( - null, - { status: 404 }, - ); - } - await next(); } };