Because /:id was declared before /me. /:id matches any string, including 'me'. Fix: declare /me before /:id, or use a different path like /me/profile.
Common Express Router Mistakes (and How to Avoid Them)
Why does /users/me get treated as /users/:id?
The answer
More FAQs in Common Express Router Mistakes (and How to Avoid Them)
Routes in wrong order, wrong mount path, router not mounted, forgetting auth, public routes inside auth router, deep nesting, mounting the same router twice, logic in routes, no validation, and sync handlers without asyncHandler.
Either the router was not mounted in app.js (app.use('/path', router)), or the mount path is wrong. Check that you mount every router with the right prefix.
You put them after router.use(auth). Public routes must be declared before router.use(auth), or in a separate router that does not apply auth.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.