Here’s a clear explanation of what I changed for anyone who might run into this problem.
Dockerfile:
# removed the "--env-file=.env"
CMD ["node", "build/index.js"]
Docker run is now:
docker run -p 3000:3000 -e PUBLIC_BACKEND_URL=http://localhost:5062 frontend
Code Changes:
import { env } from '$env/dynamic/public';
const backendUrl = env.PUBLIC_BACKEND_URL;
add .env to dockerignore and rename the env right from VITE_BACKEND_URL => PUBLIC_BACKEND_URL
Thanks a lot @brunnerh for your answer
I think you have to install Node 20.6+ or dotenv.