NuxtN
Nuxt2y ago
Dilly

useRuntimeConfig() is returning undefined values

In my
.env
file I have something like this:

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
  },


But when I try to access that value like this:

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 }}


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?
Was this page helpful?