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
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
When using the @nestjs/serve-static module, the server serves any path and does not return a 404 error even if the requested resource does not exist.
Minimal reproduction of the problem with instructions
nest new testcase
npm install --save @nestjs/serve-static
Import ServeStaticModule.forRoot({ rootPath: join(process.cwd(), 'client') }) in app.module.ts
Create folder testcase/client
Create index file index.html under the testcase/client
npm run start
Make request at curl --location --request GET 'localhost:3000/foo'
Got response HTTP/1.1 200 OK but expected HTTP/1.1 404 Not Found
What is the motivation / use case for changing the behavior?
In general, "serve-static" should follow the usual logic while serving files. If requested resource does not exists, an error is returned. Or in documentation should have a place where described this behavior and provided some instruction for handling that situations.
Environment
Nest version: 7.2.0
For Tooling issues:
- Node version: v12.16.3
- Platform: Windows
Others:
The text was updated successfully, but these errors were encountered:
I'm submitting a...
Current behavior
When using the
@nestjs/serve-static
module, the server serves any path and does not return a 404 error even if the requested resource does not exist.Project folder structure
. ├── client │ └── index.hml ├── src │ ├── app.module.ts
Input Code
Testing
Request an existing resource
Response
HTTP/1.1 200 OK
Request a nonexistent resource
Response
HTTP/1.1 200 OK
Expected behavior
Request a nonexistent resource
Response
HTTP/1.1 404 Not Found
Minimal reproduction of the problem with instructions
nest new testcase
npm install --save @nestjs/serve-static
ServeStaticModule.forRoot({ rootPath: join(process.cwd(), 'client') })
inapp.module.ts
testcase/client
index.html
under thetestcase/client
npm run start
curl --location --request GET 'localhost:3000/foo'
HTTP/1.1 200 OK
but expectedHTTP/1.1 404 Not Found
What is the motivation / use case for changing the behavior?
In general, "serve-static" should follow the usual logic while serving files. If requested resource does not exists, an error is returned. Or in documentation should have a place where described this behavior and provided some instruction for handling that situations.
Environment
The text was updated successfully, but these errors were encountered: