Prerequisites
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.
Prerequisites
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 fromreq.urlbefore it reaches the middleware.For example, a request to
/api/resource?foo=bar&baz=quxresults in the middleware receivingreq.urlas/resourceinstead 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.urlin the middleware should be/resource?foo=bar&baz=qux— with the prefix stripped but the query string preserved.Actual behavior:
req.urlis/resource— query string is lost.