79462906

Date: 2025-02-24 08:56:18
Score: 1
Natty:
Report link

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.

The official documentation for the solution is ENV and Node

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Whitelisted phrase (-1): solution is
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @brunnerh
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Sniphs