-
+page.svelte
.env
build with ADAPTER=node run with now run again with it is not picking up new dynamic value Should SveltKit My observation but when application is build into docker container and run in production with changing environment variable value, it is not printing new value but only prints what was provided during build time. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Yes. You should use When static, you should use the env key (ex
|
Beta Was this translation helpful? Give feedback.
-
my requirements is not static. |
Beta Was this translation helpful? Give feedback.
-
Hi xmlking, I've managed to get a working stackblitz reproduction here. One reason why it doesn't change could be that the page has been prerendered? That would explain why the data doesn't change at runtime. |
Beta Was this translation helpful? Give feedback.
-
yes this code is invoked in home page where I enabled prerendered , the code where I am using I previous had const appUrl = dev ? 'http://localhost:5173' : dynPubEnv.PUBLIC_BASE_URL; but applied a temp workaround by no relaying on const appUrl = browser ? window.location.origin : dynPubEnv.PUBLIC_BASE_URL; when page rendered on server side(SSR) first time, it still depends on I am also suspecting since I am using const for variable , it may not get updated when server pushed dynamic value. |
Beta Was this translation helpful? Give feedback.
-
pre-rendering makes lesson learned: |
Beta Was this translation helpful? Give feedback.
Hi xmlking,
I've managed to get a working stackblitz reproduction here.
You'll need to run
npm run build
and then your usual commandPUBLIC_BASE_URL=https://test2.domain.com node build/
.Notice that there is no .env file and it relies on the env variable specified in the command.
One reason why it doesn't change could be that the page has been prerendered? That would explain why the data doesn't change at runtime.