Skip to content

Query parameters are lost during locale redirection #1060

@tsurumeso

Description

@tsurumeso

Description

I am deploying a Next.js (Pages Router) application with i18n enabled using OpenNext.

When a user accesses the root path (/) and is redirected to a non-default locale (e.g., /en) based on their browser's language settings, any query parameters present in the original URL are lost during the redirection.

This behavior differs from the local Next.js environment (next dev / next start), where query parameters are correctly preserved.

Environment

OpenNext version: 3.9.4
Next.js version: 14.2.33

To Reproduce

  1. Initialize a Next.js project

    npx create-next-app@14 . 
    # Select "Pages Router"
    npm install next-i18next react-i18next i18next
  2. Configure i18n

    // next-i18next.config.mjs
    export const i18n = {
        defaultLocale: 'ja',
        locales: ['en', 'ja'],
    }
    // next.config.mjs
    import { i18n } from './next-i18next.config.mjs';
    
    const nextConfig = {
        i18n,
        reactStrictMode: true,
    };
    
    export default nextConfig;
  3. Deploy using SST

    npx sst@latest init
    npx sst deploy --stage production
  4. Change your browser's preferred language to English.

  5. Access the deployed root URL with query parameters: https://example.com/?xxx=yyy

Expected behavior

The user should be redirected to the English locale path with query parameters preserved: https://example.com/en?xxx=yyy

Actual behavior

The user is redirected to the English locale path, but query parameters are missing: https://example.com/en

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions