-
Notifications
You must be signed in to change notification settings - Fork 62
Description
I'm submitting a...
[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
So if you setup the ServeStaticModule and provide serveStaticOptions: { fallthrough: false }, the module reports a 500 (Internal Server) error.
I don't know why this is not coming clearly to me, but I want to change the 500 error to a 404, because the file was not found.
I tried to use a global Internal Server filter and match the route in the case of 500 errors, but that wasn't possible because for some reason the filter doesn't get hit. I must be missing something higher level about NestJS.
Expected behavior
I expect there to be an ergonomic way to handle errors when fallthrough is set to false.
Minimal reproduction of the problem with instructions
Use the example in the nest repo: https://github.com/nestjs/nest/blob/master/sample/24-serve-static/src/app.module.ts#L8
and configure your ServeStaticModule to also serve your home directory (just an example) include serveStaticOptions: { fallthrough: false }
. Then after you have set up the mount point, start the server and enter a URL under the mount point that would not exist in your home directory. Your browser should report a 500 error.
What is the motivation / use case for changing the behavior?
It currently seems either impossible or not easily discoverable on how a developer can catch the serve-static 500 error and change it to a 404 for when a file is not found.
Environment
Nest version: 7.0.2
Honestly maybe this is an issue for the serve-static repo. I am unsure.