Link to the code that reproduces this issue
https://github.com/LuukSantegoeds/nextjs-searchparams-issue
To Reproduce
Within the linked repository:
- Navigate to http://localhost:3000/route-default?foo=bar (default runtime) and validate that the searchParam is received by the route by checking the json response
- Navigate to http://localhost:3000/route-edge?foo=bar (edge runtime) and validate that the searchParam is received by the route by checking the json response
- Navigate to http://localhost:3000/middleware/route-edge?bar=foo (edge runtime) and validate that a searchParam is added by the middleware to the searchParam already provided
- Navigate to http://localhost:3000/middleware/route-default?bar=foo where no will see that no additional searchParam is added by the middleware
Current vs. Expected behavior
I would expect that the searchParam added by the middleware (in case of the default runtime) would also be received by the route handler, just like with the edge runtime.
This only occurs in combination with a rewrite in the middleware. I you were to disable the middleware and do direct requests to the route handler, searchParams are received in both runtime situations as demonstrated within the first 2 steps.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Enterprise
Available memory (MB): 32488
Available CPU cores: 16
Binaries:
Node: 20.9.0
npm: 10.1.0
Yarn: N/A
pnpm: 8.15.7
Relevant Packages:
next: 14.2.2 // Latest available version is detected (14.2.2).
eslint-config-next: 14.2.2
react: 18.2.0
react-dom: 18.2.0
typescript: 5.4.5
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Middleware & route handlers
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
This was tested locally
Link to the code that reproduces this issue
https://github.com/LuukSantegoeds/nextjs-searchparams-issue
To Reproduce
Within the linked repository:
Current vs. Expected behavior
I would expect that the searchParam added by the middleware (in case of the default runtime) would also be received by the route handler, just like with the edge runtime.
This only occurs in combination with a rewrite in the middleware. I you were to disable the middleware and do direct requests to the route handler, searchParams are received in both runtime situations as demonstrated within the first 2 steps.
Provide environment information
Which area(s) are affected? (Select all that apply)
Middleware & route handlers
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
This was tested locally