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

fix: statusCode in rootRedirect not working with strategy 'prefix' #2785

Merged

Conversation

BobbieGoede
Copy link
Collaborator

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Resolves #2758

I think the rootRedirect.statusCode was ignored because the request was redirected twice, once from / to the configured rootRedirect.path (e.g. about) with the statusCode, then again because /about doesn't exist for strategy prefix so it will be redirected to /en/about while ignoring rootRedirect configuration, as it's no longer redirecting on root.

This PR changes rootRedirect to try and translate the redirect path, so that a single redirection happens with the configured status code.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@BobbieGoede BobbieGoede requested a review from kazupon February 13, 2024 21:20
@BobbieGoede BobbieGoede self-assigned this Feb 13, 2024
Copy link
Collaborator

@kazupon kazupon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has passed testing, so I think the logic is fine. Once you have fixed my review point, you can merge them!

src/runtime/utils.ts Outdated Show resolved Hide resolved
@BobbieGoede BobbieGoede merged commit 933a092 into nuxt-modules:main Feb 14, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

statusCode in rootRedirect not working with strategy 'prefix'
2 participants