serveStatic() doesn't use the 404 handler when the file is missing
innovatedev-john-pope opened this issue · comments
innovatedev-john-pope commented
With these routes:
{
"/:filename+": serveStatic("public", { baseUrl: import.meta.url }),
404: () => new Response("not found", { status: 404 }),
}
If I try going to a file that doesn't exist, it causes a 500 error and the response has an error message containing the file path, not the 404:
{"error":"No such file or directory (os error 2), open '/var/www/deno/public/missing.png'"}
Using the intervene
option doesn't work either as the error is thrown before the intervene
function is called.