feat: configurable localePrefix via NEXT_PUBLIC_LOCALE_PREFIX#182
Open
shukiv wants to merge 1 commit intobulwarkmail:mainfrom
Open
feat: configurable localePrefix via NEXT_PUBLIC_LOCALE_PREFIX#182shukiv wants to merge 1 commit intobulwarkmail:mainfrom
shukiv wants to merge 1 commit intobulwarkmail:mainfrom
Conversation
Allow the next-intl localePrefix mode to be set via environment variable at build time, defaulting to the existing 'never' behavior. This is useful when proxying Bulwark under a sub-path (where 'never' can trigger rewrite loops) or when users prefer URL-embedded locales (/en/settings vs /settings). Usage: NEXT_PUBLIC_LOCALE_PREFIX=always npm run build Accepted values: 'never' (default), 'always', 'as-needed'.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow the next-intl
localePrefixmode to be configured via theNEXT_PUBLIC_LOCALE_PREFIXenv var at build time. Default behavior ('never') is unchanged.Motivation
Two use cases where the hardcoded
'never'mode is problematic:Proxied under a sub-path. When Bulwark is reverse-proxied under a path prefix (e.g.
/webmail),localePrefix: 'never'can trigger next-intl rewrite loops because locale detection conflicts with the proxy's path handling. Switching to'always'resolves this by making the locale explicit in URLs.Operator preference. Some deployments prefer URL-embedded locales (
/en/settings) over cookie-driven detection (/settings) for link shareability, analytics, and caching.Changes
i18n/routing.ts: readlocalePrefixfromprocess.env.NEXT_PUBLIC_LOCALE_PREFIXwith'never'as default; accept the three standard next-intl values ('never' | 'always' | 'as-needed')Usage
When unset, the existing behavior (
'never') is preserved — no breaking change for existing deployments.Test plan
NEXT_PUBLIC_LOCALE_PREFIX=never(default) — verify URLs like/settingsworkNEXT_PUBLIC_LOCALE_PREFIX=always— verify URLs like/en/settingswork and locale switcher generates prefixed URLsNotes
This pairs with #181 (configurable basePath) for deployments proxying under a sub-path.