diff --git a/CHANGELOG.md b/CHANGELOG.md index 261de87721..5830eb99e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Our versioning strategy is as follows: * `[templates/nextjs-sxa]` Fixed Image component when there is using Banner variant which set property background-image when image is empty. ([#1689](https://github.com/Sitecore/jss/pull/1689)) ([#1692](https://github.com/Sitecore/jss/pull/1692)) * `[templates/nextjs-sxa]` Fix feature `show Grid column` in Experience Editor. ([#1704](https://github.com/Sitecore/jss/pull/1704)) * `[sitecore-jss-nextjs] [templates/nextjs-xmcloud]` SDK initialization rejections are now correctly handled. Errors should no longer occur after getSDK() promises resolve when they shouldn't (for example, getting Events SDK in development environment) ([#1712](https://github.com/Sitecore/jss/pull/1712) [#1715](https://github.com/Sitecore/jss/pull/1715) [#1716](https://github.com/Sitecore/jss/pull/1716)) +* `[sitecore-jss-nextjs]` Fix redirects middleware for working with absolute url where is using site language context ([#1727](https://github.com/Sitecore/jss/pull/1727)) ### 🛠 Breaking Changes diff --git a/packages/sitecore-jss-nextjs/src/middleware/redirects-middleware.ts b/packages/sitecore-jss-nextjs/src/middleware/redirects-middleware.ts index a17ecd4474..63b212cb84 100644 --- a/packages/sitecore-jss-nextjs/src/middleware/redirects-middleware.ts +++ b/packages/sitecore-jss-nextjs/src/middleware/redirects-middleware.ts @@ -12,7 +12,7 @@ import { import { debug } from '@sitecore-jss/sitecore-jss'; import { MiddlewareBase, MiddlewareBaseConfig } from './middleware'; -const REGEXP_CONTEXT_SITE_LANG = new RegExp(/\$siteLang/, 'gi'); +const REGEXP_CONTEXT_SITE_LANG = new RegExp(/\$siteLang/, 'i'); const REGEXP_ABSOLUTE_URL = new RegExp('^(?:[a-z]+:)?//', 'i'); /** @@ -101,7 +101,10 @@ export class RedirectsMiddleware extends MiddlewareBase { // Find context site language and replace token if ( REGEXP_CONTEXT_SITE_LANG.test(existsRedirect.target) && - !REGEXP_ABSOLUTE_URL.test(existsRedirect.target) + !( + REGEXP_ABSOLUTE_URL.test(existsRedirect.target) && + existsRedirect.target.includes(hostname) + ) ) { existsRedirect.target = existsRedirect.target.replace( REGEXP_CONTEXT_SITE_LANG,