fix(nuxt): handle symbol keys in wrapped runtime config

This commit is contained in:
Daniel Roe 2024-06-10 23:42:55 +01:00
parent 9655ce6f62
commit 13fec55c10
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -563,8 +563,8 @@ function wrappedConfig (runtimeConfig: Record<string, unknown>) {
const keys = Object.keys(runtimeConfig).map(key => `\`${key}\``)
const lastKey = keys.pop()
return new Proxy(runtimeConfig, {
get (target, p: string, receiver) {
if (p !== 'public' && !(p in target) && !p.startsWith('__v') /* vue check for reactivity, e.g. `__v_isRef` */) {
get (target, p, receiver) {
if (typeof p === 'string' && p !== 'public' && !(p in target) && !p.startsWith('__v') /* vue check for reactivity, e.g. `__v_isRef` */) {
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.`)
}
return Reflect.get(target, p, receiver)