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

feat: set baseUrl via runtimeConfig #1920

Merged

Conversation

BobbieGoede
Copy link
Collaborator

@BobbieGoede BobbieGoede commented Mar 9, 2023

πŸ”— Linked issue

#1908

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Allows us to set the baseUrl via runtimeConfig as follows:

export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      i18n: {
        baseUrl: 'https://example.com',
      },
    },
  },
})

This way the baseUrl can be overwritten by setting the NUXT_PUBLIC_I18N_BASE_URL environment variable, which makes it easier to deploy from development, to staging and production environments without rebuilding or making changes to code.

I added some debug logs for easier debugging which configuration is being used to set the baseUrl.

The current implementation works by settings public.i18n.baseUrl, if there is a preference to have it in the secret/private runtimeConfig instead I can change it accordingly. Because of this I haven't added documentation to this PR yet.

There may be other configurations we could also add runtimeConfig support for, I'll keep that in mind when adding documentation if this feature gets approved.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly. (see description)

Copy link
Collaborator

@kazupon kazupon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!
This is awesome contribution!

You can ready for docs

@BobbieGoede
Copy link
Collaborator Author

@kazupon I have added documentation for the functionality, I tried to keep it generic in case other options will support setting through runtimeConfig in the future.

@kazupon
Copy link
Collaborator

kazupon commented Mar 11, 2023

@BobbieGoede
Thank you!
The docs look good to me!

@kazupon kazupon merged commit caa697c into nuxt-modules:next Mar 11, 2023
8 checks passed
DarthGigi pushed a commit to DarthGigi/i18n that referenced this pull request Apr 16, 2024
* feat: add baseUrl runtimeConfig support

* test: add baseUrl runtimeConfig test

* docs: add runtimeConfig page

* docs: fix incorrect environment variable name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow defining baseUrl via runtimeConfig
2 participants