Skip to content

Server-side redirect for root path (/) no longer works in v10 - breaking change from v9 #3913

@konkol00

Description

@konkol00

Environment

Reproduction

Reproduction

Steps to reproduce:

  1. Create a new Nuxt 3 project with @nuxtjs/i18n@^10.2.1

  2. Configure i18n with:
    typescript
    export default defineNuxtConfig({
    modules: ['@nuxtjs/i18n'],
    i18n: {
    defaultLocale: 'pl',
    strategy: 'prefix',
    locales: ['pl', 'en'],
    detectBrowserLanguage: {
    useCookie: true,
    redirectOn: 'root'
    }
    }
    })

  3. Build and run the app

  4. Test with: curl -I http://localhost:3000/

Expected: HTTP 302 redirect to /pl
Actual: HTTP 200 with full HTML content

Compare with v9: Same config in v9 returns HTTP 302 redirect

Describe the bug

Problem
After upgrading from @nuxtjs/i18n v9 to v10, the server-side redirect from root path (/) to the default locale (e.g., /pl) no longer works. This causes SEO issues with duplicate content.

v9 Behavior (Working)

curl -I https://site.com/
# → HTTP/2 302
# → location: /pl

v10 Behavior (Not Working)

curl -I https://site.com/
# → HTTP/2 200
# → (returns full HTML content)

The redirect only happens client-side via JavaScript, which means:
Search engine bots see duplicate content (/ and /pl both return 200 with identical content)
curl and non-JS clients never get redirected
This is a regression in SEO functionality

Configuration

export default defineNuxtConfig({
  i18n: {
    defaultLocale: 'pl',
    strategy: 'prefix',
    redirectStatusCode: 308,
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'LangRedirection',
      redirectOn: 'root',
    },
    locales: ['pl', 'en', 'uk']
  }
})

Expected Behavior
Root path (/) should return a server-side HTTP redirect (302/308) to the detected/default locale path (e.g., /pl), just like it did in v9.

Actual Behavior
Root path (/) returns 200 OK with full HTML, and redirect only happens client-side via JavaScript. Non-root paths like /about correctly redirect to /pl/about with 308.

Documentation Issues

  1. redirectStatusCode docs say it applies "except the root URL ('/')" but don't explain how to handle root URL
  2. redirectOn: 'root' suggests it should redirect on root, but it doesn't do server-side redirect
  3. No migration guide explaining this breaking change or the workaround

Additional context

Questions

  1. Is this intentional behavior in v10? If so, why?
  2. Should this be documented in the migration guide?
  3. Is there a built-in way to achieve server-side redirect for root that I'm missing?
  4. If custom middleware is required, should this be mentioned in the docs?

Environment
@nuxtjs/i18n: ^10.2.1
nuxt: ^3.17.5
Deployment: Vercel

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions