Skip to content

Environment Variables Reference ​

Pending model review

This page retains legacy instructions and is not the current API contract. Course/section endpoints have been removed; executable scene code is not supported. Use the current integration guide. Do not initialize an existing database from these legacy instructions.

MakiMath services are configured via .env files or system environment variables. Under Node.js 22+, native --env-file loading is fully supported.

Backend Environment Variables (maki-math-backend) ​

1. Server & Network Configurations ​

VariableDefaultRequiredDescription
HOST127.0.0.1NoHTTP bind interface. Production should bind to localhost and route traffic through Nginx.
PORT3000NoInternal port listened by Fastify.
TRUST_PROXYloopbackNoReverse proxy trust level:
• loopback (recommended): Trust local Nginx; extracts real client IP from the rightmost X-Forwarded-For;
• false: Disable proxy trust; reads direct socket IP;
• CIDR (e.g. 10.0.0.0/8): For separate reverse proxy instances.
LOG_LEVELinfoNoLogging verbosity (fatal, error, warn, info, debug, trace).

2. PostgreSQL Database Connection ​

VariableDefaultRequiredDescription
PGHOSTlocalhostNoPostgreSQL host address.
PGPORT5432NoPostgreSQL port.
PGUSERpostgresNoDatabase user account.
PGPASSWORD""YesDatabase user password. A strong password is required for production.
PGDATABASEmaki_math_devYesTarget database name (maki_math for production).

3. JWT Authentication & Sessions ​

VariableDefaultRequiredDescription
JWT_SECRETInternal dev keyYes (Prod)Secret key used to sign and verify Access Tokens. Generate via openssl rand -hex 32.
JWT_EXPIRES_IN2hNoAccess Token validity duration (15m, 2h, 1d).
JWT_REFRESH_EXPIRES_IN7dNoRefresh Token lifecycle duration (default 7 days).

4. Communication & Storage Paths ​

VariableDefaultRequiredDescription
PAYLOAD_SECRET_KEYInternal dev keyYes (Prod)Secret key for transport payload protection. Throws fatal exception if unset in NODE_ENV=production.
TYPST_BINtypstNoPath to Typst CLI executable if not on system PATH.
CACHE_DIR<root>/cacheNoServer temporary compilation cache directory.
UPLOAD_DIR<root>/uploadsNoStorage root for uploaded attachments.

Production .env Template ​

ini
# ---------- Server Network ----------
HOST=127.0.0.1
PORT=3000
TRUST_PROXY=loopback
LOG_LEVEL=info

# ---------- PostgreSQL 16 ----------
PGHOST=127.0.0.1
PGPORT=5432
PGUSER=maki
PGPASSWORD=YourStrongDatabasePassword2026!
PGDATABASE=maki_math

# ---------- JWT Authentication ----------
JWT_SECRET=c2e841f4862b9a716c52d00fb8a2e1d74c3e8095b281f692019c43e7168d3a51
JWT_EXPIRES_IN=2h
JWT_REFRESH_EXPIRES_IN=7d

# ---------- Communication Security ----------
PAYLOAD_SECRET_KEY=9a3f2b8c1e7d4a0f8b2c6e1d5a9f3b7c

Frontend Environment Variables (maki-math-frontend) ​

The Vite frontend injects variables prefixed with VITE_:

VariableDefaultDescription
VITE_API_BASE_URLEmpty string (same-origin)API base prefix. With Nginx proxying /api, keep empty to ensure clean same-origin traffic.