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

Not found error with Express route but it works! #1523

Closed
frederikhors opened this issue Aug 11, 2018 · 7 comments
Closed

Not found error with Express route but it works! #1523

frederikhors opened this issue Aug 11, 2018 · 7 comments

Comments

@frederikhors
Copy link

frederikhors commented Aug 11, 2018

I have a problem with my express app:

https://glitch.com/edit/#!/enthusiastic-velociraptor

When I navigate to GET /graphql it gives me Playground but in console I have a Not found

Why?

Reproducible with these steps:

@sbrichardson
Copy link
Contributor

I don't get it, I would check the network tab. Not Found on the base route shows up because there isn't a favicon, but that's typical if you don't handle that case. No issue other than the favicon on the base route for me.

@frederikhors
Copy link
Author

Not. It's not the favicon the problem. Try to go back and forward in the browser!

@frederikhors
Copy link
Author

image

@sbrichardson
Copy link
Contributor

sbrichardson commented Aug 12, 2018

It looks like you are adding a middleware on all routes, to call 404?

The error handler in Express is only invoked when it has 4 arguments (err, req, res, next).

Or you can add a catchall to the app stack, like link mentioned below. Quick glance, may not be correct.

https://stackoverflow.com/questions/11500204/how-can-i-get-express-js-to-404-only-on-missing-routes

@frederikhors
Copy link
Author

frederikhors commented Aug 13, 2018

I think I'm good as it is. Because I started a new express-generator app with:

express --view=pug myapp

and it wrote these files:

./app.js:

image

and routes/index.js:

image

You can try it with:

  • npm install express-generator -g
  • express --view=pug myapp

I have and I think the problem is just with apollo-server.

@frederikhors
Copy link
Author

I found this problem: https://stackoverflow.com/questions/51826711/express-js-error-handler-doesnt-work-if-i-remove-next-parameter

But now the error handler with next works, and I have the same problem with different error:

Error: /app/views/error.hbs: Can't set headers after they are sent.

image

Reproducible with these steps:

@JacksonKearl
Copy link

Closing this for now as it's quite old and it seems to be an error in how you're using express. If you still need help feel free to reopen and let us know updated steps on how to reproduce it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants