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

feat: add redirectStatusCode option #1471

Open
wants to merge 1 commit into
base: v7
Choose a base branch
from

Conversation

Matiyeu
Copy link

@Matiyeu Matiyeu commented Jul 30, 2022

This PR add ability to customize the status code to redirect unprefixed route to the default locale(when strategy: prefix) or default locale to unprefixed route (when strategy: prefix_and_default)

example :

{
  strategy: 'prefix',
  redirectStatusCode: 301
}

domain.com => 301 => domain.com/en
domain.com/about-us => 301 => domain.com/en/about-us

@Matiyeu Matiyeu changed the title add redirectStatusCode option feat: add redirectStatusCode option Jul 30, 2022
@rchl
Copy link
Collaborator

rchl commented Jul 31, 2022

I don't like how generic this setting is named and at the same time not explaining exactly what it does. To average user it won't be clear in what circumstances this redirect applies without analyzing the code.

But probably the bigger problem is that in most cases it wouldn't be safe to override this setting and people might corner themselves into issues because of using it.

For example with this option configured to respond with 301, if someone comes to a site and gets redirected from an english to german locale but then wants to manually switch to english then it won't be possible because the browser will force-redirect back to german.

I think that an option like this would only make sense if it only applied in more specific cases where it would be appropriate. For example when the URL that triggered the redirect is 404. And it shouldn't apply if the redirect was due to auto-detecting browser locale as then the user might want to switch back to locale that it redirected from.
But that would require more serious changes in the logic.

@ineshbose ineshbose added the v7 label May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants