Dilly
Dilly
NNuxt
Created by Dilly on 4/2/2024 in #❓・help
useRuntimeConfig() is returning undefined values
In my .env file I have something like this:
NUXT_PUBLIC_LOGIN_DOMAINS="domain1.com,domain2.com"
NUXT_PUBLIC_LOGIN_DOMAINS="domain1.com,domain2.com"
In my nuxt.config.ts file I have this:
runtimeConfig: {
loginDomains: process.env.NUXT_PUBLIC_LOGIN_DOMAINS
},
runtimeConfig: {
loginDomains: process.env.NUXT_PUBLIC_LOGIN_DOMAINS
},
But when I try to access that value like this:
const { loginDomains } = useRuntimeConfig()
console.log(loginDomains)
const { loginDomains } = useRuntimeConfig()
console.log(loginDomains)
It just prints out undefined. Yet if I have this in my template code on that same page:
{{ loginDomains }}
{{ loginDomains }}
I can see the value show up when I reload the page and then immediately disappear. What the heck? It's like loginDomains does have the value but then it gets set to undefined without me doing anything?
20 replies