nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.75k stars 483 forks source link

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

Closed okj579 closed 9 months ago

okj579 commented 9 months ago

Environment

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

@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 commented 9 months ago

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