-
Notifications
You must be signed in to change notification settings - Fork 278
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
#534241: [sitecore-jss-nextjs][middleware-redirect]added handling with token $siteLang #1454
Conversation
cbfb700
to
874845f
Compare
packages/create-sitecore-jss/src/templates/nextjs-sxa/src/lib/middleware/plugins/redirects.ts
Outdated
Show resolved
Hide resolved
packages/sitecore-jss-nextjs/src/middleware/redirects-middleware.ts
Outdated
Show resolved
Hide resolved
…middleware redirect. added DefaultPlugin for siteResolver
packages/create-sitecore-jss/src/templates/nextjs-sxa/src/lib/site-resolver/plugins/default.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please check linting, the check is currently failing.
…tPlugin from nextjs-sxa side
89a2f36
to
dff757a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good (approved), but I do have a question about the $siteLang token in general. If the intent is to always replace with the context site's default language, then this satisfies the requirements. However, I imagine it's more useful to replace with the context language (i.e. from NextUrl.locale).
For example, if I have a single site (default language = 'en') with 2 language versions ('en' and 'da-DK') and am using Next.js i18n sub-path routing, I would want to be able to configure a redirect target like:
pattern: /not-found
> target: http://mysite.com/$contextLang/found
So that this would be the result:
http://mysite.com/en/not-found >http://mysite.com/en/found
http://mysite.com/da-DK/not-found >http://mysite.com/da-DK/found
With $siteLang, this would be the result:
http://mysite.com/en/not-found >http://mysite.com/en/found
http://mysite.com/da-DK/not-found >http://mysite.com/en/found
packages/sitecore-jss-nextjs/src/middleware/redirects-middleware.test.ts
Outdated
Show resolved
Hide resolved
Yeah, but in this situation we not use token $siteLang it will work the same without token, right? |
Co-authored-by: Adam Brauer <[email protected]>
Oh really? Just to confirm... You're saying that if I have this redirect configured: pattern: /not-found > target: http://mysite.com/found then these requests would redirect as follows? Guess I'm just trying to think of the business value in being able to redirect to the site's configured default language (vs the route's context language). |
I checked it and it works so as you write /not-found -> /redirected-link |
Description / Motivation
Added a new handling for token $siteLang(context site language) in middleware redirect
Testing Details
Types of changes