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

statusCode in rootRedirect not working with strategy 'prefix' #2758

Closed
okj579 opened this issue Feb 6, 2024 · 4 comments · Fixed by #2785
Closed

statusCode in rootRedirect not working with strategy 'prefix' #2758

okj579 opened this issue Feb 6, 2024 · 4 comments · Fixed by #2785
Assignees
Labels
🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage routing v8

Comments

@okj579
Copy link

okj579 commented Feb 6, 2024

Environment

  • Operating System: Linux
  • Node Version: v20.11.0
  • Nuxt Version: 3.9.1
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: pnpm@8.14.1
  • Builder: -
  • User Config: extends, app, i18n
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-tdp4cc?file=nuxt.config.ts

To reproduce, open the preview in a new tab and watch Network Devtools while navigating to /. It will show a 302 redirect, even though 307 has been configured.

Describe the bug

When using rootRedirect, the statusCode option is ignored (actually overwritten afterwards, I believe) and a 302 Found is returned.

Additional context

No response

Logs

No response

@BobbieGoede BobbieGoede added v8 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage routing and removed pending triage labels Feb 6, 2024
@BobbieGoede BobbieGoede changed the title statusCode in rootRedirect not working statusCode in rootRedirect not working with strategy 'prefix' Feb 6, 2024
@BobbieGoede
Copy link
Collaborator

Thanks for reporting, after some initial debugging it looks like this happens when the 'prefix' is being used. The correct statusCode is being used when using other strategies, will look into this later.

@readio
Copy link

readio commented Feb 7, 2024

Hi @BobbieGoede Is it possible to change the 302 redirects to a 301 without using rootRedirect?

We want all our default locale redirects to be 301s.

For example:

https://domain.com/ > https://domain.com/en 
https://domain.com/catgeory-page > https://domain.com/en/catgeory-page

@BobbieGoede
Copy link
Collaborator

@readio
I'm not sure if that's configurable at the moment, also not sure if you mean in v7 or v8 (based on your other issue). I suggest opening a separate issue as a feature request or opening a separate discussion if you have questions.

@BobbieGoede
Copy link
Collaborator

The fix for this issue is included in the latest edge release, I've changed your reproduction with it installed to demonstrate here.

BobbieGoede added a commit to BobbieGoede/i18n that referenced this issue Mar 21, 2024
BobbieGoede added a commit that referenced this issue Mar 21, 2024
DarthGigi pushed a commit to DarthGigi/i18n that referenced this issue Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage routing v8
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants