Skip to content

app.use('/prefix', fn) strips query strings from req.url since v9.2.0 #248

@panva

Description

@panva

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.7.4

Plugin version

9.2.0

Node.js version

24.13.1

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

26.3

Description

Since v9.2.0, when middleware is registered with a path prefix via app.use('/prefix', fn), the query string is stripped from req.url before it reaches the middleware.

For example, a request to /api/resource?foo=bar&baz=qux results in the middleware receiving req.url as /resource instead of /resource?foo=bar&baz=qux.

This was not the case in v9.1.0.

Link to code that reproduces the bug

https://gist.github.com/panva/dd9197ce97d7daffc0ad341b5516d192

Expected Behavior

req.url in the middleware should be /resource?foo=bar&baz=qux — with the prefix stripped but the query string preserved.

Actual behavior: req.url is /resource — query string is lost.

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