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 #2443

Closed
3 of 4 tasks
existe-deja opened this issue Sep 25, 2023 · 5 comments
Closed
3 of 4 tasks

Support different domains config at runtime #2443

existe-deja opened this issue Sep 25, 2023 · 5 comments
Assignees

Comments

@existe-deja
Copy link

Describe the feature

One build to rule them all!
A good practice is to be able to deliver a project on a staging or prod environment just but changing some environment variables. It would be nice to have the ability to set the related domain for a locale at runtime level.

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

@cjpearson
Copy link
Contributor

I also need this behavior and have a WIP patch. It allows overriding a locale's domain at runtime by setting the NUXT_PUBLIC_I18N_LOCALES_{locale}_DOMAIN environment variable.

cjpearson added a commit to cjpearson/i18n that referenced this issue Sep 26, 2023
@kazupon kazupon self-assigned this Sep 28, 2023
cjpearson added a commit to cjpearson/i18n that referenced this issue Sep 28, 2023
BobbieGoede pushed a commit to BobbieGoede/i18n that referenced this issue Sep 29, 2023
cjpearson added a commit to cjpearson/i18n that referenced this issue Sep 29, 2023
BobbieGoede pushed a commit to BobbieGoede/i18n that referenced this issue Sep 30, 2023
BobbieGoede pushed a commit to BobbieGoede/i18n that referenced this issue Sep 30, 2023
BobbieGoede added a commit to BobbieGoede/i18n that referenced this issue Sep 30, 2023
BobbieGoede added a commit to BobbieGoede/i18n that referenced this issue Sep 30, 2023
BobbieGoede added a commit to BobbieGoede/i18n that referenced this issue Oct 1, 2023
BobbieGoede pushed a commit to BobbieGoede/i18n that referenced this issue Oct 1, 2023
BobbieGoede pushed a commit to BobbieGoede/i18n that referenced this issue Oct 1, 2023
BobbieGoede pushed a commit that referenced this issue Oct 1, 2023
* feat: set locale domains via runtimeConfig (#2443)

* docs: add example of runtime domain configuration to the guide
@BobbieGoede
Copy link
Collaborator

Resolved by #2446!

@existe-deja
Copy link
Author

I think I missed something in the setup or maybe it's not working at all.

When I build my project with an certain .env file, domain values are not updated when I run it with another .env file.

To reproduce:

1/ edit your /etc/hosts with at least the following content to be able to have different local domains

127.0.0.1	localhost local-dev-en local-dev-nl local-dev-ja local-prod-en local-prod-nl local-prod-ja

2/ clone the project https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-jvph93?file=.template.env and yarn dev with the following .env

NUXT_PUBLIC_I18N_LOCALES_EN_DOMAIN=local-dev-en:3000
NUXT_PUBLIC_I18N_LOCALES_NL_DOMAIN=local-dev-nl:3000
NUXT_PUBLIC_I18N_LOCALES_JA_DOMAIN=local-dev-ja:3000

Everything works fine, the domain is correctly mapped to the locale

3/ with the same .env file, yarn build and then run it with the .env
In Ubuntu I use this command set -a && source .env && set +a && node .output/server/index.mjs

Everything works fine as in dev mode.

4/ update the .env file with the following values

NUXT_PUBLIC_I18N_LOCALES_EN_DOMAIN=local-prod-en:3000
NUXT_PUBLIC_I18N_LOCALES_NL_DOMAIN=local-prod-nl:3000
NUXT_PUBLIC_I18N_LOCALES_JA_DOMAIN=local-prod-ja:3000

5/ run the previous build with the new values without rebuilding it
run set -a && source .env && set +a && node .output/server/index.mjs again.
The new domains are injected into the runtime config but not into the i18n module domain detection, it keeps the the env from the build time.

What am I missing? 🤔

@existe-deja
Copy link
Author

I think it needs to be reopened or to provide a fully working project

@bcadu
Copy link

bcadu commented Dec 6, 2023

I suspect this issue is not fixed.
I've opened a new ticket #2602

DarthGigi pushed a commit to DarthGigi/i18n that referenced this issue Apr 16, 2024
…modules#2446)

* feat: set locale domains via runtimeConfig (nuxt-modules#2443)

* docs: add example of runtime domain configuration to the guide
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

5 participants