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

Support different domains config at runtime #2602

Open
bcadu opened this issue Dec 6, 2023 · 10 comments
Open

Support different domains config at runtime #2602

bcadu opened this issue Dec 6, 2023 · 10 comments

Comments

@bcadu
Copy link

bcadu commented Dec 6, 2023

Environment

  • Operating System: Linux
  • Node Version: v18.14.2
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, modules, pages, runtimeConfig, i18n
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

Reproduction

The code
https://stackblitz.com/edit/nuxt-starter-lm7gng

And a minimal Apache configuration

<VirtualHost *:443>
    
    ServerName fr.localhost
    
    ServerAlias fr.localhost2
    ServerAlias en.localhost
    ServerAlias es.localhost
    
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/localhost.crt
    SSLCertificateKeyFile /etc/ssl/certs/localhost.key
    
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
</VirtualHost>

Describe the bug

I'm encountering an issue with the Nuxt i18n module where its behavior differs between the development and production environments, specifically after a single build process.

Development Environment:

  • The module functions as expected, aligning with the values set in the .env file.

Production Environment:

  • After building the project, I observed two different behaviors based on how the application is started:

    1. First Start (npm run start):

      • The application behaves as expected. The default domain value from the build process is utilized.
        {
            code: "fr",
            domain: process.env.NUXT_PUBLIC_I18N_LOCALES_FR_DOMAIN || "fr.localhost",
            file: "fr-FR.json",
        }
        Accessing https://fr.localhost/, the following is displayed:
        • Index Page
        • "Bienvenue"
        • Locale: fr
        • Site name: My Site Name
    2. Second Start (npm run start:2):

      • When accessed via https://fr.localhost2/, the results are inconsistent:
        • Index Page
        • "Welcome"
        • Locale: en (unexpectedly switches to the default locale)
        • Site name: My Site Name 2

      In this case, while the NUXT_PUBLIC_SITE_NAME variable is correctly recognized at runtime, the NUXT_PUBLIC_I18N_LOCALES_FR_DOMAIN variable is not, and the application defaults to the default locale.

I suspect there might be an issue with how the i18n module handles domain values in production, particularly after the initial build. Any insights or suggestions on resolving this discrepancy would be greatly appreciated.

Additional context

No response

Logs

No response

@melaniehuet
Copy link

Hi all,
Agree with @bcadu, hosting on different domains using process.env variables doesn't work.
By adding domains in runtimeConfig, it seems that NuxtLinks are well updated but hosting directly on the runtimeConfig domain does not work.
https://github.com/nuxt-modules/i18n/blob/main/specs/different_domains.spec.ts#L121 => Serving on "kr.staging.nuxt-app.localhost" does not work.
Thanks :)

@existe-deja
Copy link

I coded the fix + tests but I'm unable to push my branch to the repository. @rchl do I need any permissions for this?

@bcadu
Copy link
Author

bcadu commented Apr 11, 2024

Hi @existe-deja,
We're also waiting for a patch for this feature, which we absolutely need. Would it be possible to get yours?
Thanks

@patrob1
Copy link

patrob1 commented May 3, 2024

Hi All,
Agree with @melaniehuet , I'm also trying to host on different domain for me the env variables are recognized as domain names but I still get language prefixes for all other languages than the default one. I have also tried to use 'no_prefix' strategy but that one is buggy when it is together with differentDomains: true, so it cannot be used.
Looking forward for the patch, thank you in advance

@nezaBacar
Copy link

nezaBacar commented Jun 14, 2024

Hello,
We're also looking forward to this feature working as intended :) We look forward to the patch.
Thanks

@OlePc
Copy link

OlePc commented Jul 3, 2024

Any update on this?

@OlePc
Copy link

OlePc commented Jul 3, 2024

I coded the fix + tests but I'm unable to push my branch to the repository. @rchl do I need any permissions for this?

You probably need to fork the project, and submit a PR after adding your fix. Can I see your fix anywhere?

@Belorusov
Copy link

any update or maybe workaround?

@cernymatej
Copy link
Contributor

none that I'm aware of.. still waiting for these domains issues to be resolved

@Belorusov
Copy link

fyi: NUXT_PUBLIC_I18N_BASE_URL not works in runtime too

@BobbieGoede BobbieGoede removed the v8 label Nov 4, 2024
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

10 participants