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

Infinite reload with differentDomains: true #1563

Closed
1 of 2 tasks
ghost opened this issue Oct 13, 2022 · 13 comments
Closed
1 of 2 tasks

Infinite reload with differentDomains: true #1563

ghost opened this issue Oct 13, 2022 · 13 comments
Assignees

Comments

@ghost
Copy link

ghost commented Oct 13, 2022

Version

@nuxtjs/i18n: 8.0.0-alpha.3
nuxt: 3.0.0-rc.11

Nuxt configuration

  • Applies to a site deployed to a static server (site generated with nuxt generate)
  • Applies to a site deployed to a server with a Node backend

@nuxtjs/i18n configuration

i18n: {
        locales: [
            {
              code: 'en',
              domain: mydomain.com
            },
            {
              code: 'fr',
              domain: mydomain.fr
            }
        ],
        differentDomains: true,
        defaultLocale: 'fr',
        vueI18n: {
            legacy: false,
            locale: 'fr',
            messages: {
                en: {
                    welcome: 'Welcome'
                },
                fr: {
                    welcome: 'Bienvenue'
                }
            }
        }
    }

Steps to reproduce

I use pm2 to manage the app execution.
Set differentDomains: true in i18n config, run yarn build, and launch app with pm2. Access the app via FR or EN domain, the refresh loop begins.
When differentDomains is set to false, the issue doesn't appear.
In the doc I see "// TODO: 🚧 This feature is not implemented yet.", but it seems working because when I access app with FR or EN domain, my content is in correct language, but the refresh loop make the UI unusable.

Thanks.

@ghost ghost added the bug 🐛 label Oct 13, 2022
@kazupon kazupon added the v8 label Oct 14, 2022 — with Volta.net
@MosheL
Copy link

MosheL commented Oct 16, 2022

detectBrowserLanguage: false can help you until they will fix

@ghost
Copy link
Author

ghost commented Oct 17, 2022

Unfortunately, this setting doesn't change anything, refresh loop persists.

@boboldehampsink
Copy link

Seeing the same thing - already have detectBrowserLanguage: false

Copy link
Collaborator

kazupon commented Oct 30, 2022

sorry, for late reply.

Unfortunately, I could not reproduce this issue in v8.0.0-beta.2 😞
Could you give us to your reproduction repo with github repo or stackblitz please? 🙏
And We hope you would like to try to use v8.0.0-beta.2, wheather this issue will be reproduced

@boboldehampsink
Copy link

@kazupon still seeing this in beta 3

This is my config:

  i18n: {
    strategy: 'no_prefix',
    differentDomains: true,
    detectBrowserLanguage: false,
    baseUrl: process.env.LOCALE === 'de' ? process.env.SITEURL_DE : process.env.SITEURL,
    locales: [
      {
        name: 'nederlands',
        code: 'nl',
        iso: 'nl-NL',
        file: 'nl.json',
        domain: process.env.SITEURL,
      },
      {
        name: 'deutsch',
        code: 'de',
        iso: 'de-DE',
        file: 'de.json',
        domain: process.env.SITEURL_DE,
      },
    ],
    langDir: 'assets/i18n/',
    defaultLocale: process.env.LOCALE,
    lazy: true,
  },

@maxsolovev
Copy link

Same problem

Copy link
Collaborator

kazupon commented Nov 2, 2022

@boboldehampsink
Thank you for your feedback!
I could reproduce loop redirection.
I'll try to fix this issue.

@kazupon kazupon self-assigned this Nov 2, 2022
@maxsolovev
Copy link

This is my config.
Doesn't work with both detectBrowserLanguage: {...} and detectBrowserLanguage: false

export default defineNuxtConfig({
  modules: ['@nuxtjs/i18n'],
  i18n: {
    locales: [
      {
        code: 'en',
        domain: 'mysite.test:3000',
      },
      {
        code: 'de',
        domain: 'mysite.testde:3000',
      },
    ],
    trailingSlash: true,
    differentDomains: true,
    defaultLocale: 'en',
    strategy: 'prefix_and_default', 
    detectBrowserLanguage: false,
    // detectBrowserLanguage: {
    //   useCookie: false,
    //   redirectOn: 'root',
    //   fallbackLocale: 'en',
    //   // alwaysRedirect: true,
    // },
    vueI18n: {
      legacy: false,
      messages: {
        en: {
          welcome: 'Welcome',
        },
        de: {
          welcome: 'Willkommen',
        },
      },
    },
  },
})

Copy link
Collaborator

kazupon commented Nov 3, 2022

I've just released @nuxtjs/i18n-edge@8.0.0-beta.3-27791028.494116d edge version
I believe this issue is fixed.
you can try to use it.

@ghost
Copy link
Author

ghost commented Nov 3, 2022

I just tested your release, but refresh loop is always here for me.

@maxsolovev
Copy link

maxsolovev commented Nov 3, 2022

Thank you @kazupon
It works perfectly

Will you port this to @nuxtjs/i18n?

@ghost
Copy link
Author

ghost commented Nov 3, 2022

@maxsolovev what is your config? Same as above? For me the redirect loop persists.

@maxsolovev
Copy link

Yes, it's same. But there were problems with routing.
screencast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants