express_jwt icon indicating copy to clipboard operation
express_jwt copied to clipboard

verifyJWT Middleware Causes Unauthorized Error for Nonexistent Routes (404).

Open r0-0hit opened this issue 1 year ago • 0 comments

Screenshot 2024-12-28 122858 When attempting to access nonexistent routes, the application incorrectly returns an "Unauthorized" error instead of the expected "404" response. This issue occurs because the verifyJWT middleware is applied globally before the 404 handler. As a result, verifyJWT intercepts the request for nonexistent routes and responds with "Unauthorized" if the JWT is missing or invalid, preventing the 404 handler from executing.

This behavior creates confusion for users accessing non-protected, nonexistent routes and misrepresents the actual error.

r0-0hit avatar Dec 28 '24 07:12 r0-0hit