Most upvoted solution already gave an answer on how to fix if you still decided to use import.meta.env
.
If you don't have to use import.meta.env
, you can manually set window.env = { key: process.env[key] }
during SSR. This would make the value available when loaded on client, effectively mimic import.meta.env
.
An advantage of this is that the Docker user doesn't have to rebuild the image. They can just run the container (with prebuilt image) with their .env
file, and the process described above will load it properly.