kit icon indicating copy to clipboard operation
kit copied to clipboard

.env variables are being read in production, documentation says they are not

Open Antoine-lb opened this issue 1 year ago • 0 comments

Describe the bug

The documentation states "[in adapter-node] In production, .env files are not automatically loaded.", but variables that start with VITE_, PUBLIC_ and SECRET_ are being loaded without dotenv.

The fix would be to update the documentation to avoid surprises.

note: I think this is the reason of why so many people struggle with the ORIGIN env var, this makes it hard to debug

Reproduction

(there most be a simpler but I don't know how to print all the variables)

  1. Add SECRET_API_KEY and BODY_SIZE_LIMIT=Infinity variable in a .env result: SECRET_API_KEY is available but I get hit with Payload Too Large

  2. Add BODY_SIZE_LIMIT=Infinity in the CLI before the production build my production cmd: BODY_SIZE_LIMIT=Infinity pm2 start node --name="prod" -- ./build/index.js result: everything works

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (1) x64 AMD EPYC 7543 32-Core Processor
    Memory: 1.37 GB / 1.91 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.11.0 - /usr/local/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 10.2.4 - /usr/local/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: ^3.1.1 => 3.1.1
    @sveltejs/adapter-node: ^4.0.1 => 4.0.1
    @sveltejs/kit: ^2.5.0 => 2.5.0
    @sveltejs/vite-plugin-svelte: ^3.0.2 => 3.0.2
    svelte: ^4.2.10 => 4.2.10
    vite: ^5.1.1 => 5.1.1

Severity

annoyance

Additional Information

I volunteer to update the doc. If interested let me know.

Antoine-lb avatar Feb 18 '24 13:02 Antoine-lb