Skip to content

[BUG] All undefined routes throw ReferenceError: createError is not defined instead of proper 404 error #126

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

Open
rohansen856 opened this issue May 13, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@rohansen856
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. start the server and go to http://localhost:3090/ in the browser
  2. go to any undefined route (like http://localhost:3090/xyz)
  3. It throws a createError is not defined error like this:

Image

Expected behavior
It should throw a 404 error (not found) like this:
Image

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Ubuntu 24.04LTS
  • Browser Chrome
  • Version: 133.0.6943.126 (Official Build) (64-bit)

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
The problem can be simply solved by uncommenting line 11 in /src/app.js. As createError variable has been mistakenly commented and later used without further declaration, it throws the above mentioned error.

app.use(function (req, res, next) {
  next(createError(404))
})
@rohansen856
Copy link
Author

@behives @jsanter27 I have solved this issue and opened up a PR #127 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants