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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Modules] Central configuration place for baseUrl #8713

Closed
manniL opened this issue Jan 27, 2021 · 2 comments
Closed

[Modules] Central configuration place for baseUrl #8713

manniL opened this issue Jan 27, 2021 · 2 comments

Comments

@manniL
Copy link
Member

manniL commented Jan 27, 2021

Is your feature request related to a problem? Please describe.

Several modules (sitemap, i18n, axios, http, and possibly many more 馃檲) are asking in some way for the app's baseUrl. Unfortunately, most of them have their own configuration option for it (e.g. publicRuntimeConfig.axios.baseUrl, sitemap.baseUrl, ...). This creates a little more boilerplate than necessary while the url itself stays the same and reduces the risk of forgetting to set a baseUrl somewhere.

Describe the solution you'd like

Ideally, the modules access some "general" place for the baseUrl, e.g. publicRuntimeConfig.baseUrl. This would reduce the boilerplate and makes configuration easier - set and forget 馃構.
This could be documented at each module documentation but maybe also in the main Nuxt documentation?

To avoid breaking changes, modules could use the "general" configuration as a fallback if no specific value is set. This could also make migration easier as it is not immediately necessary but can be hinted via warning.

Copy link
Member

Atinux commented Jan 28, 2021

I think we already discussed about something like this with @pi0 and it is a good idea.

I would maybe prefix it with nuxt.baseURL

@danielroe
Copy link
Member

In Nuxt 3 this is now configurable via app.baseURL which is accessible within modules by accessing that from the nuxt options object. At runtime it is accessible via useRuntimeConfig().app.baseURL

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

3 participants