Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/loaders/express.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ export class ExpressLoader extends AbstractLoader {

app.use((err: any, req: any, _res: any, next: Function) => {
if (isRouteExcluded(req, options.exclude)) {
const method = httpAdapter.getRequestMethod(req);
const url = httpAdapter.getRequestUrl(req);
return next(new NotFoundException(`Cannot ${method} ${url}`));
return next(err);
}

if (err instanceof HttpException) {
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/express-adapter.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ describe('Express adapter', () => {
return request(server)
.get('/api/404')
.expect(404)
.expect(/Not Found/)
.expect(/Cannot GET \/api\/404/);
.expect({ statusCode: 404, message: 'Not Found' }); // Default NestJS NotFoundException response
});
});

Expand Down