diff --git a/composables/featureFlags.ts b/composables/featureFlags.ts index 5b4e539f7a..b1bfade2d4 100644 --- a/composables/featureFlags.ts +++ b/composables/featureFlags.ts @@ -68,6 +68,8 @@ const COOKIE_OPTIONS: CookieOptions = { export const useFeatureFlags = () => useState('featureFlags', () => { + const config = useRuntimeConfig() + const savedFlags = useCookie('featureFlags', COOKIE_OPTIONS) if (!savedFlags.value) { @@ -76,6 +78,15 @@ export const useFeatureFlags = () => const flags: AllFeatureFlags = JSON.parse(JSON.stringify(DEFAULT_FEATURE_FLAGS)) + const overrides = config.public.featureFlagOverrides as PartialFeatureFlags + for (const key in overrides) { + if (key in flags) { + const flag = key as FeatureFlag + const value = overrides[flag] as (typeof flags)[FeatureFlag] + flags[flag] = value + } + } + for (const key in savedFlags.value) { if (key in flags) { const flag = key as FeatureFlag diff --git a/nuxt.config.ts b/nuxt.config.ts index ae818e0751..de237b12a7 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -387,7 +387,7 @@ function isProduction() { } function getFeatureFlagOverrides() { - return process.env.FLAG_OVERRIDES + return JSON.parse(process.env.FLAG_OVERRIDES ?? '{}') } function getDomain() {