Configuration

Configuration

Docker and Node read environment variables (see docker.env.example). On Cloudflare, MASTER_KEY is a Worker secret and everything else lives in wrangler.jsonc.

Environment variables

VariableDefaultWhat it does
MASTER_KEYGenerated into DATA_DIR/master.key for local setupsEncrypts every file and sensitive field. 32 bytes, base64 or hex. Required with a remote database or S3 storage.
PUBLIC_URLThe address of the requestUsed in invite, reset and MCP links. An https:// address also turns on secure cookies.
PORT8080Port the server listens on.
DATA_DIR./dataWhere the SQLite database, local files and generated key live.
MAX_UPLOAD_MB25 (Cloudflare: 10)Largest single file accepted.
DATABASE_URLSQLite file in DATA_DIRA libsql:// URL to use Turso instead.
DATABASE_AUTH_TOKENToken for the Turso database.
STORAGE_DRIVERfss3 to store files in an S3-compatible bucket.
S3_ENDPOINTe.g. https://<account-id>.r2.cloudflarestorage.com or https://s3.us-west-004.backblazeb2.com
S3_REGIONauto for R2, the bucket's region for B2 or AWS.
S3_BUCKETBucket name.
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEYA key limited to that bucket.
S3_PREFIXOptional folder inside the bucket, e.g. kagaz/.

On Cloudflare

Change these in wrangler.jsonc and run npm run deploy again:

Rotate secrets with npx wrangler secret put MASTER_KEY. Changing the master key makes existing files unreadable, so only do this on an empty vault or right before restoring a backup.

Where data lives

SetupRecordsFiles
CloudflareD1R2
Docker (default)data/kagaz.dbdata/files/
Container hostTursoR2, B2, MinIO or AWS S3

Files are always encrypted before they are stored. Document numbers, notes and remembered PDF passwords are encrypted in the database too.

Server commands

For Docker and Node setups. Inside the container, run them with docker compose exec kagaz node dist/node/server/node/cli.js <command>.

CommandWhat it does
reset-link <email>Prints a one-time password reset link, valid for 24 hours.
make-admin <email>Makes someone an admin, for example if the only admin has left.
usersLists accounts.
gen-keyPrints a new random master key.

On Cloudflare, an admin can make reset links from Settings › Members instead.