You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rewrite works as expected when hitting /uk. However when I navigate to /en-GB it redirects to the default locale (/en-US/en-GB) when I would expect it to redirect to the custom prefix of /uk.
Verifications
I've verified that the problem I'm experiencing isn't covered in the docs.
I've searched for similar, existing issues on GitHub and Stack Overflow.
Thanks for the question, this works as intended in fact.
/en-GB is really an unknown route if you configure a custom prefix like /uk and is treated the same way as e.g. /unknown. If you want to add additional redirects on top, you can compose the middleware accordingly.
I understand that's the current behavior and I am currently working around it by checking the request url pathname to see if it begins with any of the locale codes mapping to custom prefixes and redirecting to its associated one if it does. I figured since all of that data is provided to next-intl it could handle that check internally.
It was an unexpected behavior given my use case. Would it make sense for this to be the default behavior if we supply a custom user-facing prefix?
I figured since all of that data is provided to next-intl it could handle that check internally.
It would definitely be possible, that's correct.
I'm a bit hesitant to add it though because:
I'd be worried if there could be false positives (even if not likely). By not including a redirect here, users can optionally add this if relevant.
Including a redirect here would theoretically be a breaking change (also arguably not likely, but still).
I'm unsure how often this would really be accessed by a user. If a redirecting locale prefix is nothing you link to on your website, I can only imagine a user typing in this manually.
Do you have other aspects to this in mind from your perspective?
Description
With the following config for middleware:
Rewrite works as expected when hitting
/uk
. However when I navigate to/en-GB
it redirects to the default locale (/en-US/en-GB
) when I would expect it to redirect to the custom prefix of/uk
.Verifications
Mandatory reproduction URL
https://github.com/c-tuck/next-intl-redirect-bug-verbose-prefixes
Reproduction description
Steps to reproduce:
/en-GB
/en-US/en-GB
instead of redirect to/uk
Expected behaviour
Locales with custom prefixes should redirect to its custom prefix instead of redirecting to the default locale.
The text was updated successfully, but these errors were encountered: