Replies: 1 comment
-
Hmm, can't see an obvious problem, but if you start with the code from |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The
localePrefix: "as-needed"
configuration is not behaving as expected for default locale routes. According to the documentation, this setting should allow the default locale to be accessed without a prefix, but currently it only works for the root path (/
) and not for other routes like/contact
.Expected Behavior
With
localePrefix: "as-needed"
anddefaultLocale: "tr"
, the following URLs should work:/
→ Turkish homepage (default locale, no prefix)/contact
→ Turkish contact page (default locale, no prefix)/en
→ English homepage (non-default locale, prefix required)/en/contact
→ English contact page (non-default locale, prefix required)This is the standard behavior seen on major international websites like [CoinMarketCap] https://coinmarketcap.com/currencies/xrp/ (English default, no prefix) vs [CoinMarketCap Turkish]https://coinmarketcap.com/tr/currencies/xrp/ (Turkish with
/tr/
prefix).Current Behavior
Currently with
localePrefix: "as-needed"
:/
→ Works (Turkish homepage)/contact
→ 404 (should work for default locale)/tr/contact
→ Works (explicit prefix)/en/contact
→ Works (non-default locale)Reproduction
Minimal reproduction setup:
src/i18n/routing.ts:
middleware.ts:
File structure:
Steps to reproduce:
/
→ ✅ Works (Turkish default)/contact
→ ❌ 404 error/tr/contact
→ ✅ Works/en/contact
→ ✅ WorksWorkaround Attempted
Created duplicate pages at root level (e.g.,
src/app/contact/page.tsx
) that import and render the locale-specific components, but this creates:Environment
Request
Could you please provide guidance on how to properly configure
localePrefix: "as-needed"
to work for all routes of the default locale, not just the root path?The goal is to have a clean URL structure where:
/
,/contact
,/about
)/en/contact
,/fr/about
)This would align with common international website patterns and provide better UX for the primary audience.
Beta Was this translation helpful? Give feedback.
All reactions