-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Incorrect serialization of array query parameters in redirect logic #28687
Copy link
Copy link
Labels
🐛 bugSomething isn't workingSomething isn't working
Description
Issue Summary
Incorrect serialization of query parameters containing array values in redirect logic.
In getServerSideProps, context.query is cast to Record<string, string> and passed to URLSearchParams. However, Next.js query params can be string | string[], which leads to incorrect serialization of array values.
Steps to Reproduce
- Open a URL with repeated query params, for example:
/john?user=john&user=doe - Trigger a flow that causes redirect (e.g., dynamic group redirect).
- Observe the generated redirect URL.
Actual Results
- Query params with multiple values are serialized incorrectly:
user=john,doe - This changes the structure of the query and may break downstream logic expecting multiple values.
Expected Results
- Query params should preserve multiple values correctly:
user=john&user=doe
Technical details
-
Affected file:
apps/web/server/lib/[user]/getServerSideProps.ts -
Problematic code:
new URLSearchParams(context.query as Record<string, string>) -
Environment:
Next.js App Router
Node.js (any version)
Evidence
- Based on inspection of Next.js query typing:
context.query: { [key: string]: string | string[] } - Reproduced by passing multiple query params with the same key and observing incorrect serialization via URLSearchParams.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🐛 bugSomething isn't workingSomething isn't working