Skip to content

Incorrect serialization of array query parameters in redirect logic #28687

@Akash504-ai

Description

@Akash504-ai

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

  1. Open a URL with repeated query params, for example: /john?user=john&user=doe
  2. Trigger a flow that causes redirect (e.g., dynamic group redirect).
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions