Open blu14x opened 7 months ago
I have worked on runtimeConfig
support for the detectBrowserLanguage
a while ago (https://github.com/nuxt-modules/i18n/pull/2576) but unfortunately it's blocked until the next nitropack
release which includes https://github.com/unjs/nitro/pull/1831. I'll update/sync the feature PR soon, I think the next nitropack
release will be sometime this month.
The icing on the cake would be that the option accepts a function with the context as a parameter that returns either the domain string or null.
This wouldn't be possible using runtimeConfig
as functions are not serializable, I'm also a bit hesitant to add function support in the options as the same support for baseUrl
has been a source of issues, though it's not out of the question if it is a common request.
I have worked on
runtimeConfig
support for thedetectBrowserLanguage
a while ago (#2576) ...
Oh awesome. I quickly skimmed through that. That would be even better than just handling individual options of detectBrowserLanguage.
If I understand correctly, this would allow:
export default defineNuxtConfig({
runtimeConfig: {
public: {
i18n: {
detectBrowserLanguage: {
cookieDomain: null,
},
},
},
},
})
Which makes it overwritable by NUXT_PUBLIC_I18N_DETECT_BROWSER_LANGUAGE_COOKIE_DOMAIN
.
I guess?
Describe the feature
Heyho
Currently we can specify the cookieDomain in the
nuxt.config.ts
to bake it into the NuxtI18nOptions, or leave it null so it defaults to the host.Problem
Sometimes, however, if it is used in several different deployments, it may be necessary to adapt the domain for the cookie accordingly. But right now, it is not possible to customise the domain for different deployments.
Solution
Introduce an environment variable, similar to baseUrl, to change the value for cookieDomain during runtime. Suggestion:
NUXT_PUBLIC_I18N_COOKIE_DOMAIN
The icing on the cake would be that the option accepts a function with the context as a parameter that returns either the domain string or null.
Additional information
Final checks