question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with router

See original GitHub issue
	router.get('/test', jwt({
		secret: 'test'
	}), (req, res ) => {
		if(!req.user.admin) return res.status(401);
		res.status(200);
	})

is my route, when i try to access the route i get this error:

Error
   at middleware (C:\Users\jerom\Git\web\node_modules\express-jwt\lib\index.js:75:21)
   at Layer.handle [as handle_request] (C:\Users\jerom\Git\web\node_modules\express\lib\router\layer.js:95:5)
   at next (C:\Users\jerom\Git\web\node_modules\express\lib\router\route.js:131:13)
   at Route.dispatch (C:\Users\jerom\Git\web\node_modules\express\lib\router\route.js:112:3)
   at Layer.handle [as handle_request] (C:\Users\jerom\Git\web\node_modules\express\lib\router\layer.js:95:5)
   at C:\Users\jerom\Git\web\node_modules\express\lib\router\index.js:277:22
   at Function.process_params (C:\Users\jerom\Git\web\node_modules\express\lib\router\index.js:330:12)
   at next (C:\Users\jerom\Git\web\node_modules\express\lib\router\index.js:271:10)
   at router.use (C:\Users\jerom\Git\web\routes\api.js:19:3)
   at Layer.handle [as handle_request] (C:\Users\jerom\Git\web\node_modules\express\lib\router\layer.js:95:5)

can’t figure out why i’m getting this error. Is this a known issue with the express router?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

9reactions
steve-heinecommented, Mar 2, 2017

I ran into the issue and digging in…it looks like this is as designed. The best workaround I see is to add this to the bottom of your express app before opening the port

app.use(function (err, req, res, next) {
  if (err.name === 'UnauthorizedError') {
    res.status(401).send(err.inner);
  }
});

this should provide a clearer error message

8reactions
fuxescommented, Jan 6, 2017

@jerome724 could you please share what was your problem? I’m having the same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The most common Wi-Fi problems and how to fix them
Resetting your router can fix myriad issues, and an inability to connect is one of them. Press the Reset button on the back...
Read more >
No Internet Connection? How to Troubleshoot Internet Issues
Restarting your modem and router should be the first thing you do when encountering an internet signal issue. Don't skip this step!
Read more >
errorElement v6.6.1 - React Router
When a route does not have an errorElement , errors will bubble up through parent routes. This lets you get as granular or...
Read more >
How to troubleshoot five common routing errors - TechTarget
Troubleshooting router errors is made easier with this tip, which covers the five major routing errors -- filtering redistribution, mismatched ...
Read more >
Troubleshooting Router Error Responses | Cloud Foundry Docs
Troubleshooting Router Error Responses ; Log Formatting. Levels; Message Contents ; Diagnose Gorouter Errors. Gorouter Cannot Connect to the App ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found