i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Infinite reload with differentDomains: true

Open mcskumy opened this issue 3 years ago • 2 comments

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)
  • [x] 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.

mcskumy avatar Oct 13 '22 16:10 mcskumy

detectBrowserLanguage: false can help you until they will fix

MosheL avatar Oct 16 '22 07:10 MosheL

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

ghost avatar Oct 17 '22 08:10 ghost

Seeing the same thing - already have detectBrowserLanguage: false

boboldehampsink avatar Oct 25 '22 12:10 boboldehampsink

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

kazupon avatar Oct 30 '22 05:10 kazupon

@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,
  },

boboldehampsink avatar Nov 01 '22 10:11 boboldehampsink

Same problem

maxsolovev avatar Nov 01 '22 20:11 maxsolovev

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

kazupon avatar Nov 02 '22 17:11 kazupon

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',
        },
      },
    },
  },
})

maxsolovev avatar Nov 02 '22 17:11 maxsolovev

I've just released @nuxtjs/[email protected] edge version I believe this issue is fixed. you can try to use it.

kazupon avatar Nov 03 '22 07:11 kazupon

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

ghost avatar Nov 03 '22 09:11 ghost

Thank you @kazupon It works perfectly

Will you port this to @nuxtjs/i18n?

maxsolovev avatar Nov 03 '22 09:11 maxsolovev

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

ghost avatar Nov 03 '22 10:11 ghost

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

maxsolovev avatar Nov 03 '22 11:11 maxsolovev