Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route handler does not receive searchParams set by middleware without runtime edge #64776

Open
LuukSantegoeds opened this issue Apr 19, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template.

Comments

@LuukSantegoeds
Copy link

LuukSantegoeds commented Apr 19, 2024

Link to the code that reproduces this issue

https://github.com/LuukSantegoeds/nextjs-searchparams-issue

To Reproduce

Within the linked repository:

  1. 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
  2. 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
  3. 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
  4. 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

@LuukSantegoeds LuukSantegoeds added the bug Issue was opened via the bug report template. label Apr 19, 2024
@ventsislavnikolov
Copy link

In v14.1.4 searchParams with middleware is working, after updating on 14.2.0-14.2.2, the searchParams is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants