Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/middleware/serveStatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ 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 @@ -64,6 +73,7 @@ export const serveStatic = (options: ServeStaticOptions = { root: "" }) => {
* TODO: Maybe we should handle the type of error that fetch would throw?
*/
log.debug(`Static file: ${path} does not exist, continuing`);

await next();
}
};
Expand Down