Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal error on paths like '/static/a/abc' if 'a' is a file #80

Closed
AxlLind opened this issue Mar 25, 2019 · 1 comment · Fixed by #82
Closed

Internal error on paths like '/static/a/abc' if 'a' is a file #80

AxlLind opened this issue Mar 25, 2019 · 1 comment · Fixed by #82

Comments

@AxlLind
Copy link
Contributor

AxlLind commented Mar 25, 2019

Problem

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:

https://github.com/zeit/serve-handler/blob/d1368bf5ece565b27850ceaab2758a5ae0a4579d/src/index.js#L611

@AxlLind 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
@AxlLind
Copy link
Contributor Author

AxlLind commented Mar 28, 2019

See PR #82

@leo leo closed this as completed in #82 Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant