Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sitecore-jss-nextjs] Fix redirects with defaultLocale set to 'default' #2055

Merged
merged 2 commits into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,10 @@ Our versioning strategy is as follows:

## Unreleased

### 🐛 Bug Fixes

* `[sitecore-jss-nextjs]` Fix an endless redirect issue with [/default/(.*) -> /en/$1] redirect rule when nextjs default locale is set to default. ([#2055](https://github.com/Sitecore/jss/pull/2055))

## 22.5.2

### 🐛 Bug Fixes
Original file line number Diff line number Diff line change
@@ -82,9 +82,8 @@ export class RedirectsMiddleware extends MiddlewareBase {
req: NextRequest,
siteName: string
): Promise<RedirectResult | undefined> {
const { pathname: targetURL, search: targetQS = '', locale } = this.normalizeUrl(
req.nextUrl.clone()
);
const { pathname: targetURL, search: targetQS = '' } = this.normalizeUrl(req.nextUrl.clone());
const locale = this.getLanguage(req);
const normalizedPath = targetURL.replace(/\/*$/gi, '');
const redirects = await this.redirectsService.fetchRedirects(siteName);
const language = this.getLanguage(req);