i18n runtimeConfig different domains not working
Hi all,
in my Nuxt3 application, i have a lot of environment variables in my .env file and declare in my runtimeConfig. But when i use NUXT_PUBLIC_I18N_LOCALES_UK_DOMAIN to declare different domains in nuxt/i18n, it doesn't work. Here is my nuxt.config.ts:
Here is my .env file: And i launch my app through npm script "set -a && source ./.env && set +a && node .output/server/index.mjs" (not sure the best way) I have an apache to serve mydomain.uk and mydomain.fr (proxy to localhost:3000) Do you have an idea why it's not working ? Thanks !
Here is my .env file: And i launch my app through npm script "set -a && source ./.env && set +a && node .output/server/index.mjs" (not sure the best way) I have an apache to serve mydomain.uk and mydomain.fr (proxy to localhost:3000) Do you have an idea why it's not working ? Thanks !
14 Replies
There seems to be a bug in the module regarding this. I'm facing the same issue 😦
@melanie Did you find any solution?
@melanie check this part of the doc
@xibman The issue is that it does not work. The locale domain is not overriden with the runtime config value.
GitHub
Support different domains config at runtime · Issue #2602 · nuxt-mo...
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, ...
If anyone can get it to work, I would like to see the nuxt.config.
May be the documentation that is missing some key detail.
Hello, this is what worked for me:
(the rest continues in another message)
And finally:
Using the
npm run dev
command (bound to nuxt dev --port=3002 --host
in my package.json)
I can run it locally and my server is served through it.localhost:3002, de.localhost:3002....
NB: It also worked when I declared several env variables with NUXT_PUBLIC_I18N_LOCALES_UK_DOMAIN and so on, but I didn't want too many env variables so I managed the locale subdomain directly in the nuxt.config.ts
Hope it helpsThis will work at build time, but will not work at runtime. Many use the same build for staging and production ect., and want to set specific domains on each environment using environment variables.
According to the documentation, you should be able to overwrite the domain using the runtime config. But this does not seem to work.
Hello. @xibman i've followed the documentation you mentioned, and i agree with @OleP, this works at build time (npm run dev) but not at runtime
do you try something like this
NUXT_PUBLIC_I18N_LOCALES_UK_DOMAIN=test command to start server
It works fine for baseUrl using NUXT_PUBLIC_I18N_BASE_URL. But it does not work for domains unfortunately.
The issue is not the environment variable, but rather that the values set in the runtime config is not respected. I found that the value is set in this line: https://github.com/nuxt-modules/i18n/blob/0ef6d8b31a5e052a3326de3054e017d175af8b90/src/runtime/internal.ts#L431, but I've not managed to debug the values there.
GitHub
i18n/src/runtime/internal.ts at 0ef6d8b31a5e052a3326de3054e017d175a...
I18n module for Nuxt. Contribute to nuxt-modules/i18n development by creating an account on GitHub.
yes i've tried and it's not working
Bump for notification when an issue is here
@Baylife asda
How can this still be with 0 response / feedback for a solution?