Skip to content

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

VariablePurpose
DATABASE_URLPostgreSQL connection string (Neon). Used by DatabaseService via pg.Pool.
CLERK_SECRET_KEYClerk backend secret. Used by ClerkAuthGuard to verify JWTs via @clerk/backend.
SPOTIFY_CLIENT_IDSpotify API credential. Client-credentials flow — no user login needed.
SPOTIFY_CLIENT_SECRETSpotify API credential.
ADMIN_KEYProtects admin-only REST endpoints. Passed by callers as x-admin-key header.

Optional

VariableDefaultPurpose
PORT3000HTTP listen port.
LOG_LEVEL2 (INFO)2 = INFO, 3 = DEBUG. Controls LoggerService verbosity.
LOG_FIRESTORE_OPERATIONSfalseSet to 'true' to log every DB read/write in production (always on in development).
LOG_CACHE_OPERATIONSfalseSet to 'true' to log game-state cache hits/misses in production.
NODE_ENVStandard 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.

VariableNotes
REDIS_HOST, REDIS_PORTReserved 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_KEYSupabaseJwtGuard 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/

VariableRequiredPurpose
EXPO_PUBLIC_GAME_SERVER_URLYesBase 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_KEYYesClerk 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

VariablePurpose
GAME_SERVER_URLNestJS server base URL. Used by server-side Next.js routes to proxy admin API calls.
GAME_SERVER_ADMIN_KEYValue sent as x-admin-key header. Must match ADMIN_KEY on the server.
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYClerk publishable key (browser-side).
CLERK_SECRET_KEYClerk 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.

VariableValue
NEXT_PUBLIC_CLERK_SIGN_IN_URLPath for the sign-in page (e.g. /sign-in)
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URLWhere to go after sign-in if no redirect param
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URLWhere to go after sign-up if no redirect param

Cloudflare R2 (media uploads)

VariablePurpose
CLOUDFLARE_R2_ACCOUNT_IDCloudflare account ID
CLOUDFLARE_R2_ACCESS_KEY_IDR2 access key (S3-compatible)
CLOUDFLARE_R2_SECRET_ACCESS_KEYR2 secret key
CLOUDFLARE_R2_BUCKET_NAMETarget bucket name
NEXT_PUBLIC_R2_PUBLIC_URLPublic base URL for serving stored files

Admin Optional

VariableDefaultPurpose
PORT3001Next.js dev server port.