Skip to content

Commit 9e56b60

Browse files
committed
fix(nuxt): only log warning once per runtimeConfig key
1 parent b17aa3f commit 9e56b60

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/nuxt/src/app/nuxt.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,14 +558,18 @@ export function defineAppConfig<C extends AppConfigInput> (config: C): C {
558558
/**
559559
* Configure error getter on runtime secret property access that doesn't exist on the client side
560560
*/
561+
const loggedKeys = new Set<string>()
561562
function wrappedConfig (runtimeConfig: Record<string, unknown>) {
562563
if (!import.meta.dev || import.meta.server) { return runtimeConfig }
563564
const keys = Object.keys(runtimeConfig).map(key => `\`${key}\``)
564565
const lastKey = keys.pop()
565566
return new Proxy(runtimeConfig, {
566567
get (target, p, receiver) {
567568
if (typeof p === 'string' && p !== 'public' && !(p in target) && !p.startsWith('__v') /* vue check for reactivity, e.g. `__v_isRef` */) {
568-
console.warn(`[nuxt] Could not access \`${p}\`. The only available runtime config keys on the client side are ${keys.join(', ')} and ${lastKey}. See \`https://nuxt.com/docs/guide/going-further/runtime-config\` for more information.`)
569+
if (!loggedKeys.has(p)) {
570+
loggedKeys.add(p)
571+
console.warn(`[nuxt] Could not access \`${p}\`. The only available runtime config keys on the client side are ${keys.join(', ')} and ${lastKey}. See \`https://nuxt.com/docs/guide/going-further/runtime-config\` for more information.`)
572+
}
569573
}
570574
return Reflect.get(target, p, receiver)
571575
},

0 commit comments

Comments
 (0)