-
-
Notifications
You must be signed in to change notification settings - Fork 518
Description
Environment
- Operating System:
Darwin - Node Version:
v20.19.0 - Nuxt Version:
3.17.5 - CLI Version:
3.25.1 - Nitro Version:
2.11.12 - Package Manager:
[email protected] - Builder:
- - User Config:
compatibilityDate,devtools,css,ssr,spaLoadingTemplate,srcDir,routeRules,sitemap,site,sourcemap,modules,hooks,mazUi,lottie,vitalizer,plugins,imports,image,features,vite,nitro,i18n,ignore,runtimeConfig,experimental,build,app,$production,sentry - Runtime Modules:
@nuxt/[email protected],@nuxtjs/[email protected],[email protected],@pinia/[email protected],@nuxt/[email protected],[email protected],@vueuse/[email protected],@nuxt/[email protected],@nuxtjs/[email protected],@nuxtjs/[email protected],@nuxtjs/[email protected],[email protected],~/api,maz-ui/[email protected],@vee-validate/[email protected],[email protected],@nuxt/[email protected],@sentry/nuxt/[email protected],~/modules/authModule,~/modules/userModule,~/modules/orderModule,~/modules/calendarModule,~/modules/dietModule,~/modules/addressModule,~/modules/teamModule,~/modules/transactionModule,~/modules/pointsModule,~/modules/paymentsModule,~/modules/notificationsModule,~/modules/homeModule,~/modules/promotionModule,~/modules/menuModule,~/modules/aiModule,~/modules/cartModule - Build Modules:
-
Reproduction
Reproduction
Steps to reproduce:
-
Create a new Nuxt 3 project with
@nuxtjs/i18n@^10.2.1 -
Configure i18n with:
typescript
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
defaultLocale: 'pl',
strategy: 'prefix',
locales: ['pl', 'en'],
detectBrowserLanguage: {
useCookie: true,
redirectOn: 'root'
}
}
}) -
Build and run the app
-
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
- redirectStatusCode docs say it applies "except the root URL ('/')" but don't explain how to handle root URL
- redirectOn: 'root' suggests it should redirect on root, but it doesn't do server-side redirect
- No migration guide explaining this breaking change or the workaround
Additional context
Questions
- Is this intentional behavior in v10? If so, why?
- Should this be documented in the migration guide?
- Is there a built-in way to achieve server-side redirect for root that I'm missing?
- If custom middleware is required, should this be mentioned in the docs?
Environment
@nuxtjs/i18n: ^10.2.1
nuxt: ^3.17.5
Deployment: Vercel