satyarohith / sift

Sift is a routing and utility library for Deno Deploy.
https://deno.land/x/sift
MIT License
170 stars 14 forks source link

serveStatic() doesn't use the 404 handler when the file is missing #54

Closed innovatedev-john-pope closed 2 years ago

innovatedev-john-pope commented 2 years ago

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.