Skip to content

Documenting req.route in relation to route handlers vs middleware #1227

Description

@womcauliff

This request for docs comes from expressjs/express#4193, where the person is trying to understanding why req.route is undefined.

The answer in response wrote:

That is a distinguishing feature between middlewares and routes; routes (like app.all) have a route (visible in req.route) and middlewares do not have a route.

I encountered a similar error to the person who raised the issue, and although I understand the high-level differences between middleware and a route handler, it hadn't occurred to me that the shape of the req object is different within a route handler vs within a middleware.

I believe the docs would benefit by explaining this as explicitly as the responder did in that issue thread.

Activity

  1. arnaudoff commented on Feb 23, 2021

    @arnaudoff

    Same here. Please update the docs, I also wasted a lot of time trying to figure out what's wrong..

  2. locked and limited conversation to collaborators on Aug 2, 2025
  3. converted this issue into a discussion #2025 on Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions