GioJSdocs
On this page

[env]

Whether the .env files in the project root are loaded at startup.

gio.toml
[env]
files = false        # the process environment is all there is

By default the server loads .env.{mode}.local, .env.local, .env.{mode} and .env before anything else, and variables already in the environment win. See .env files.

Reference

KeyDefaultDescription
filesbooleantrueLoad the .env* files. Turn it off on platforms that inject the environment, so a stray file baked into an image can never add or change a variable.0 / false / empty: No .env* file is readEnv override: GIO_ENV_FILES

Behavior

  • GIO_ENV_FILES=0 (or false) skips the files and GIO_ENV_FILES=1 (or true) loads them, whatever gio.toml says. Unset or empty leaves it to the key; any other value stops startup (GIO_ENV_FILES="no" must be 0 (skip them) or 1 (load them)).
  • The files load before gio.toml is fully parsed, so this one key is read on its own first. If gio.toml has a syntax error there, or files is not a plain boolean, the files load and the full parse right after reports the problem.
  • With loading off, startup logs not loading .env files: [env] files turns them off (or GIO_ENV_FILES), and --check-config reports "envFilesDisabledBy".
  • The server, gio export, gio build standalone, the testing kit and the gio CLI all follow the key and the variable.

No key in this section logs a warning.

Examples

A container platform

Keep .env for local development, and never read it in the container:

Dockerfile
ENV GIO_ENV_FILES=0

Good to know

  • files = "no" is a startup error: invalid type: string "no", expected a boolean.
  • The files are read once, at startup; restart after editing them.

Not configurable

  • The GIO_PUBLIC_ prefix. Only variables named GIO_PUBLIC_* are inlined into client bundles; every other variable stays on the server, so a secret can only reach the browser if you name it that way.
  • NODE_ENV in a .env file is ignored with a warning: the mode is decided before the files are read.

Version history

VersionChanges
v0.1.0-beta.8Introduced, with GIO_ENV_FILES. The server loads .env files from this release on.