Skip to content

Conversation

@toakiryu
Copy link

Description

This PR fixes an issue where top-level redirects were not fully locale-aware.

The site uses an i18n routing structure where the default locale does not have a URL prefix
(e.g. /docs), while non-default locales do (e.g. /ja/docs).
However, the existing redirect rules only covered non-prefixed routes, which caused 404 pages
when navigating the site in non-default languages via the header links or the "Get Started" CTA.

Since Next.js redirects are not locale-aware by default, both route patterns must be handled
explicitly.

What was fixed

Redirect rules were updated to explicitly support both:

  • Default locale routes (e.g. /docs, /blog, /examples)
  • Locale-prefixed routes (e.g. /:locale/docs, /:locale/blog, /:locale/examples)

This ensures consistent navigation behavior across all supported languages.

Redirect behavior

  • /docs/docs/getting-started
  • /:locale/docs/:locale/docs/getting-started
  • /blog/blog/swr-v1
  • /:locale/blog/:locale/blog/swr-v1
  • /examples/examples/basic
  • /:locale/examples/:locale/examples/basic

Why this change is needed

  • The issue only affects non-default locales, making it easy to miss during development.
  • It breaks primary navigation and CTAs for localized users.
  • The fix aligns with Next.js i18n routing behavior and avoids implicit assumptions about locales.

Checklist

  • Adding new page
  • Updating existing documentation
  • Other updates (routing / redirect fix)

Note:
This description was written with AI assistance.
Please feel free to suggest wording improvements if anything sounds unnatural.

@vercel
Copy link
Contributor

vercel bot commented Dec 13, 2025

@toakiryu is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@toakiryu toakiryu changed the title Fix locale-unaware redirects for default and non-default languages fix: make redirects locale-aware Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant