Environment variables with adapter-node not completely working. #11502
-
Hi everyone! I'm using the adapter node to deploy sveltekit on node. It works well, but public (prefixed with PUBLIC_) are rendering in +page.svelte(s) as undefined. envs on +server.ts load fine. I did follow the docs and I am using dotenv: https://kit.svelte.dev/docs/adapter-node#environment-variables. Has anyone had a similar issue? If it helps, I am deploying with the help of Coolify, which using docker. Thank you! :) |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Looks like you need to import envs one by one like so:
Instead of:
@Rich-Harris this doesn't seem to be in the adapter-node docs under environment variables? If this is the expected result, should I create a PR to add the additional detail to the docs? |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issue, my "PUBLIC_" env vars are present on |
Beta Was this translation helpful? Give feedback.
-
@LGmatrix13 I ran into the same issue. I want to use dynamic public variables (= not available at build time), so your solution is not applicable, right? At least if I try it with $env/dynamic/public, it doesn't compile obviously. This is blocking us from using adapter-node unfortunately. |
Beta Was this translation helpful? Give feedback.
-
Are you running the node server directly with
then you can use on your backend with:
and on the frontend with:
|
Beta Was this translation helpful? Give feedback.
-
I'm running into this issue for the second on two production builds. We are deploying our projects using docker so we are limited in what fixes we can apply. The bigger problem is our build fails.
|
Beta Was this translation helpful? Give feedback.
-
Just spent a long time debugging this in a remote environment – I was using dynamic
|
Beta Was this translation helpful? Give feedback.
Looks like you need to import envs one by one like so:
Instead of:
@Rich-Harris this doesn't seem to be in the adapter-node docs under environment variables? If this is the expected result, should I create a PR to add the additional detail to the docs?