gio.toml
The project-root file the Rust server reads at startup for every server setting: listen address, caching, security, images, fonts, limits and rules.
#:schema ./node_modules/@gio.js/server/gio.schema.json
[app]
name = "acme"
[server]
port = 3000 # GIO_PORT or PORT overrides it
[images]
allowed_widths = [640, 828, 1080, 1200, 1920]
quality = 80Reference
File name and location
gio.toml in the project root, next to app/. The server looks for it in the parent of GIO_APP_DIR when that variable is set and the file exists there, else in the directory it was started in. The file is optional: without it every setting has its default.
Contents
TOML tables, one per section: [app], [server], [security], [cache], [images], [[fonts]], [[rate_limits]], [[redirects]] and the rest. Every key, its type, default and what turning it off costs is on gio.toml, with one page per section.
Behavior
- Read once, at startup, by the Rust server. A change takes effect when the server starts again, in development too: the dev watcher notices the edit but restarts only the Node worker, which does not read
gio.toml. Stopgio devand start it again after editing the file. - Strict. An unknown section or key anywhere stops startup, with the line and the closest valid name:
gio.toml:4: unknown key [image] - did you mean [images]?- Room for other tools. Top-level tables whose name starts with
x-([x-mytool]) are left alone. - Environment variables win for the keys that have one (
GIO_PORT,PORT,GIO_HOST,GIO_CACHE_DIR, ...)..envfiles are loaded beforegio.tomlis read, so they can set those variables too. - Editor support. The
#:schemafirst line points editors with a TOML language server (Even Better TOML / Taplo) at the schema@gio.js/serverships, for completion and hover docs.
Examples
Check the file without starting the server
npx giojs-server --check-configpnpm exec giojs-server --check-configyarn giojs-server --check-configbunx giojs-server --check-configIt loads the .env files and gio.toml exactly as startup does, runs the same validation, and prints a JSON report (errors, warnings for protections you turned off, the listen address). It exits 1 when the server would refuse to start and never binds a port, so it works as a CI step:
{"configFile":"gio.toml","envFiles":[],"envFilesDisabledBy":null,"errors":["gio.toml:4: unknown key [image] - did you mean [images]?"],"mode":"production","ok":false}Good to know
- Strictness is fixed: a misspelled security key that was silently ignored would leave a protection off. Use
[x-...]tables for anything else you want in the file. - Every protection is on by default. Turning one off or loosening it logs one startup warning naming the key, and
--check-configreports the same text (see Turning Protections On and Off). gio build standalonecopiesgio.tomlinto the deploy folder, where the server reads it at every start.- Node-side settings (plugins) are in gio.config.ts; computed rules can also go in middleware.ts.
Related
- gio.toml reference - every section and key.
- Strict by design and editor autocomplete
- Environment variables, .env files
Version history
| Version | Changes |
|---|---|
v0.1.0-beta.8 | Strict: unknown sections and keys stop startup, [x-*] tables are ignored. gio.schema.json for editors, --check-config, and a switch for every default-on protection and feature. |
v0.1.0-beta.5 | A malformed gio.toml stops startup instead of running on defaults. |
v0.1.0-beta.1 | Introduced. |