Skip to content

Commit

Permalink
exhibitionist-digital#292 serve build: fix log on return 404
Browse files Browse the repository at this point in the history
  • Loading branch information
d9k committed Dec 29, 2023
1 parent cf396c3 commit c2a17d3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/middleware/serveStatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}
};
Expand Down

0 comments on commit c2a17d3

Please sign in to comment.