Environment Variables
Complete list of environment variables for each app. Variables are read at startup — restart the service after changing them.
Server — apps/server/
Required
| Variable | Purpose |
|---|---|
DATABASE_URL | PostgreSQL connection string (Neon). Used by DatabaseService via pg.Pool. |
CLERK_SECRET_KEY | Clerk backend secret. Used by ClerkAuthGuard to verify JWTs via @clerk/backend. |
SPOTIFY_CLIENT_ID | Spotify API credential. Client-credentials flow — no user login needed. |
SPOTIFY_CLIENT_SECRET | Spotify API credential. |
ADMIN_KEY | Protects admin-only REST endpoints. Passed by callers as x-admin-key header. |
Optional
| Variable | Default | Purpose |
|---|---|---|
PORT | 3000 | HTTP listen port. |
LOG_LEVEL | 2 (INFO) | 2 = INFO, 3 = DEBUG. Controls LoggerService verbosity. |
LOG_FIRESTORE_OPERATIONS | false | Set to 'true' to log every DB read/write in production (always on in development). |
LOG_CACHE_OPERATIONS | false | Set to 'true' to log game-state cache hits/misses in production. |
NODE_ENV | — | Standard Node env. 'development' enables verbose logging regardless of LOG_LEVEL. |
Stale — in .env but not active
These keys appear in the local .env from earlier iterations. They are not read by current server code and can be removed.
| Variable | Notes |
|---|---|
REDIS_HOST, REDIS_PORT | Reserved for future Redis integration (see Roadmap). Not wired up yet. |
FIREBASE_* | Legacy. Server migrated to Neon/Drizzle; no Firebase code remains in src/. |
SUPABASE_URL, SUPABASE_SECRET_KEY | SupabaseJwtGuard exists in src/auth/ but is not applied to any route. |
CLOUDFLARE_R2_* | R2 storage is used by the admin app, not the server. Mistakenly duplicated here. |
Client — apps/client/
| Variable | Required | Purpose |
|---|---|---|
EXPO_PUBLIC_GAME_SERVER_URL | Yes | Base URL for the NestJS server (REST + Socket.IO). Falls back to http://192.168.50.22:3000 if unset. Set to the Railway URL in production. |
EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY | Yes | Clerk publishable key for the Expo SDK. |
All EXPO_PUBLIC_* variables are inlined at build time by Metro. Changing them requires a rebuild (or a new EAS build in production).
Admin — apps/band-game-admin/
Admin Required
| Variable | Purpose |
|---|---|
GAME_SERVER_URL | NestJS server base URL. Used by server-side Next.js routes to proxy admin API calls. |
GAME_SERVER_ADMIN_KEY | Value sent as x-admin-key header. Must match ADMIN_KEY on the server. |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | Clerk publishable key (browser-side). |
CLERK_SECRET_KEY | Clerk secret key (server-side Next.js routes). |
Clerk redirect config
These are read by the Clerk Next.js SDK and are not referenced explicitly in code.
| Variable | Value |
|---|---|
NEXT_PUBLIC_CLERK_SIGN_IN_URL | Path for the sign-in page (e.g. /sign-in) |
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL | Where to go after sign-in if no redirect param |
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL | Where to go after sign-up if no redirect param |
Cloudflare R2 (media uploads)
| Variable | Purpose |
|---|---|
CLOUDFLARE_R2_ACCOUNT_ID | Cloudflare account ID |
CLOUDFLARE_R2_ACCESS_KEY_ID | R2 access key (S3-compatible) |
CLOUDFLARE_R2_SECRET_ACCESS_KEY | R2 secret key |
CLOUDFLARE_R2_BUCKET_NAME | Target bucket name |
NEXT_PUBLIC_R2_PUBLIC_URL | Public base URL for serving stored files |
Admin Optional
| Variable | Default | Purpose |
|---|---|---|
PORT | 3001 | Next.js dev server port. |