You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accessing a path like static/a/abc will throw an error and respond with status code 500 if a is a file. This is because this generates an ENOTDIR error, instead of ENOENT.
We discovered this since we serve images at static/*.jpg and paths like static/*.jpg/abc returned 500 instead of 404.
Expectation
Should respond with status code 404 and show the 404 page.
Solution
In the code you check forif (err.code !== 'ENOENT'). Adding && err.code !== 'ENOTDIR' for example here makes it correctly respond with 404 instead of 500:
The text was updated successfully, but these errors were encountered:
AxlLind
changed the title
Error thrown on paths like '/static/a/abc' if 'a' is a file
Internal error on paths like '/static/a/abc' if 'a' is a file
Mar 25, 2019
Problem
Accessing a path like
static/a/abc
will throw an error and respond with status code 500 ifa
is a file. This is because this generates anENOTDIR
error, instead ofENOENT
.We discovered this since we serve images at
static/*.jpg
and paths likestatic/*.jpg/abc
returned 500 instead of 404.Expectation
Should respond with status code 404 and show the 404 page.
Solution
In the code you check for
if (err.code !== 'ENOENT')
. Adding&& err.code !== 'ENOTDIR'
for example here makes it correctly respond with 404 instead of 500:https://github.com/zeit/serve-handler/blob/d1368bf5ece565b27850ceaab2758a5ae0a4579d/src/index.js#L611
The text was updated successfully, but these errors were encountered: