N
Nuxt10mo ago
plechelmus

runtimeConfig differs on server-render vs client-rendered page

Hi, on intial page load my runtimeConfig uses the default values I set in nuxt.config.ts and does not use any NUXTPUBLIC... overrides from the environment. If I navigate to different pages, this runtimeConfig stays. But when I go to a page that only has a client component, it loads the correct runtimeConfig with the values from my environment. If I navigate to page afterwards it also keeps this runtimeConfig. Reloading the page reverts the runtimeConfig back to the default one. I use the runtimeConfig to point to the resource to load. So you can imagine this is unwanted behaviour since it now shows two different resources based on which page was visited first. What can be the issue of this? I am using the latest version of Nuxt and it is running inside Docker. If I go inside docker and run echo $NUXTPUBLIC... it shows the correct values, but they are not used by the application when first loading the page.
1 Reply
plechelmus
plechelmusOP10mo ago
runtimeConfig: {
public: {
env: "",
apiurl: "",
appmode: "",
shopslug: "",
domain: "",
version: pjson.version,
sentry: {
dsn: "",
environment: "",
},
},
},
runtimeConfig: {
public: {
env: "",
apiurl: "",
appmode: "",
shopslug: "",
domain: "",
version: pjson.version,
sentry: {
dsn: "",
environment: "",
},
},
},
This is what my runtimeConfig looks like without default values.
NUXT_PUBLIC_ENV=production

NUXT_PUBLIC_SITEMODE=site
NUXT_PUBLIC_SHOPSLUG=demowinkel
NUXT_PUBLIC_ENV=production

NUXT_PUBLIC_SITEMODE=site
NUXT_PUBLIC_SHOPSLUG=demowinkel
This is what my env variables look like It seems related to Nitro prerender crawlLinks
Want results from more Discord servers?
Add your server