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

onlyOnRoot not redirecting based on cookie in static target #887

Closed
1 task done
divine opened this issue Sep 10, 2020 · 3 comments · Fixed by #890
Closed
1 task done

onlyOnRoot not redirecting based on cookie in static target #887

divine opened this issue Sep 10, 2020 · 3 comments · Fixed by #890
Labels

Comments

@divine
Copy link

divine commented Sep 10, 2020

Version

nuxt-i18n: 6.15.0
nuxt: 2.14.4

Nuxt configuration

mode:

  • universal (static)

Nuxt-i18n configuration

i18n: {
    strategy: 'prefix',
    detectBrowserLanguage: {
      useCookie: true,
      alwaysRedirect: true,
      onlyOnRoot: true
    },
}

Reproduction Link

Demo: http://silent-watch.surge.sh/ru
Github: https://github.com/divine/i18n-static-redirect

It works on CodeSandbox because they don't support static target and runs in dev mode.

Steps to reproduce

When locale is changed cookie is being changed.

However on root path with onlyOnRoot option doesn't redirect based on stored cookie.

What is Expected?

When visiting https://silent-watch.surge.sh/ru going back to https://successful-direction.surge.sh should redirect to ru.

What is actually happening?

Redirection to /en

@rchl
Copy link
Collaborator

rchl commented Sep 10, 2020

Right, so it should redirect before updating the cookie in this case.

@rchl
Copy link
Collaborator

rchl commented Sep 11, 2020

It's the #805 fix that doesn't play well with the latest changes.

The #805 is creating a redirect route from / to the default locale. I think I can just change that from a redirect route to a normal route. It should still trigger redirect but wouldn't force it to redirect to specific (default) locale.

@rchl
Copy link
Collaborator

rchl commented Sep 11, 2020

Fix released in v6.15.1

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 a pull request may close this issue.

2 participants