Skip to content

[App Router] Configurable redirects locale prefix behavior - #577

Open
art-alexeyenko wants to merge 4 commits into
devfrom
bug/jss-10136-locale-app-router
Open

[App Router] Configurable redirects locale prefix behavior#577
art-alexeyenko wants to merge 4 commits into
devfrom
bug/jss-10136-locale-app-router

Conversation

@art-alexeyenko

Copy link
Copy Markdown
Collaborator

Description / Motivation

next-intl locale prefix behavior conflicts with SXA redirects' isLanguagePreserved switch - the latter switch overrides outcome, regardless of the languagePrefix value set for next-intl. This PR attempts to make the redirect results more predictable and configurable by renaming and reusing the localeInPath setting.

languagePrefix in next-intl appLanguagePrefix Result
'as-needed' undefined Content SDK behavior - isLanguagePreserved overrides next-intl behavior and applies locale when true
'as-needed' 'as-needed' next-intl behavior - locale prefix is never applied when locale is defaultLanguage
'always' 'always' next-intl behavior - locale prefix always applied, regardless of isLanguagePreserved
'never' 'never' next-intl behavior - locale prefix is never applied, regardless of isLanguagePreserved

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c1f3f22

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 2 packages
Name Type
@sitecore-content-sdk/nextjs Patch
create-content-sdk-app Patch

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📦 Package Size and Test Coverage Report

Package Base Size PR Size Δ Change Base Coverage PR Coverage Δ Change
analytics-core 69.05 KB 69.05 KB ✅ 0.00 KB 97.44% 97.44% 0.00%
angular 337.93 KB 337.93 KB ✅ 0.00 KB 93.85% 93.85% 0.00%
cli 61.06 KB 61.06 KB ✅ 0.00 KB 71.36% 71.36% 0.00%
content 481.96 KB 481.96 KB ✅ 0.00 KB 92.86% 92.86% 0.00%
core 122.38 KB 122.38 KB ✅ 0.00 KB 91.22% 91.22% 0.00%
create-content-sdk-app 525.12 KB 525.68 KB 🔺 +0.56 KB 96.47% 96.47% 0.00%
events 72.33 KB 72.33 KB ✅ 0.00 KB 97.97% 97.97% 0.00%
nextjs 543.01 KB 539.86 KB 🔻 -3.15 KB 91.49% 91.47% -0.02%
personalize 64.01 KB 64.01 KB ✅ 0.00 KB 99.74% 99.74% 0.00%
react 237.10 KB 237.10 KB ✅ 0.00 KB 93.95% 93.95% 0.00%
search 8.25 KB 8.25 KB ✅ 0.00 KB 98.72% 98.72% 0.00%
Total 🔻 -2.59 KB

@illiakovalenko illiakovalenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution looks even better to me - good proposal! 👍
I have one suggestion below, thinking about the future and keeping our approach library-agnostic.
If you’ve already checked this scenario, great. If not, I’d recommend double-checking it by testing these settings without LocaleProxy, following our documentation: https://doc.sitecore.com/sai/en/developers/content-sdk/20/DEFAULT/disable-multisite-and-locale-proxies.html

Comment thread packages/nextjs/src/config/define-config.ts Outdated
Comment thread packages/nextjs/src/config/define-config.ts Outdated

@illiakovalenko illiakovalenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revisit my very first comment regarding the next-intl references in our docs. Also, please double-check the build failure.

Comment thread packages/nextjs/src/proxy/redirects-proxy.ts Outdated
Comment thread packages/nextjs/src/config/define-config.ts Outdated
Comment thread .changeset/empty-years-spend.md Outdated
Comment thread .changeset/tasty-pianos-eat.md Outdated

@illiakovalenko illiakovalenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
Please see one minor comment below. Once that’s addressed, feel free to merge

---

Add `redirects.localeInPath` so App Router redirect locale handling works when LocaleProxy is removed (`x-sc-locale` is optional). `true`/`false` control path prefixes; default `null` keeps the `x-sc-locale` header fallback (non-breaking). App Router templates set `true`. No newline at end of file
Add root-level `appLocalePrefix` config so App Router redirect locale handling works when LocaleProxy is removed (`x-sc-locale` is optional). It controls whether App Router redirect targets carry a locale path prefix (`/[locale]/...`) depending on the value:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we’re kind of duplicating the changeset we added for the nextjs package here. Could we simplify it and just mention that we’ve started leveraging a new setting in our template(s)? create-content-sdk-aap doesn't really bring this feature

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.

2 participants