Configuration File
All environment variables are stored inapps/server/.env and validated by packages/api/src/config/env.ts.
Required Variables
These variables must be set for the server to start.Secret key used to sign JWT authentication tokens.Validation:Generate:
- Minimum length: 32 characters
- Maximum length: 64 characters
- Signs JWT tokens when users complete verification
- Verifies tokens on protected endpoints
- Tokens expire after 1 hour (configurable in
packages/api/src/routers/auth.ts)
Shared secret between backend and Roblox game for verification flow.Validation:Example:Generate:
- Minimum length: 64 characters
- Must be stored securely in both backend
.envand Roblox game - Never expose to clients or logs
- Sent in
x-verification-secretheader from game server scripts - Uses timing-safe comparison to prevent timing attacks
completeVerification with this secret to prove authenticity:Roblox Server Script
The Roblox place ID where users complete verification.Validation:How to find:
- Must be numeric (regex:
^\d+$) - Must be a valid Roblox place ID
- Returned to client during
beginVerification - Client directs user to join this place
- Game at this place must have integration code to call
completeVerification
- Go to your Roblox game page
- Look at the URL:
https://www.roblox.com/games/123456789/game-name - The number
123456789is your place ID
Optional Variables
These variables have sensible defaults and can be customized.Roblox authentication cookie for API requests.Usage:
- Used by
fetchRobloxUserProfileto get user data from Roblox API - Optional but may help with rate limiting
- If not provided, makes unauthenticated requests
- Never commit this to version control
- Store only in
.envfile - Cookie format:
.ROBLOSECURITY=<value>
Maximum length for chat messages in characters.Validation:Code reference:
- Must be a positive integer
- Coerced to number if provided as string
- Applied to all channels by default
- Can be overridden per channel with
CHAT_LIMITS_OVERRIDES - Enforced in
packages/api/src/routers/chat.ts
packages/api/src/routers/chat.ts
Number of messages allowed per rate limit window.Validation:How it works:
- Must be a positive integer
- Coerced to number if provided as string
- Users can send this many messages per window before being rate limited
- Applied per user (by
robloxUserId) - Can be overridden per channel with
CHAT_LIMITS_OVERRIDES
- User sends message → timestamp recorded
- System checks timestamps in current window
- If count exceeds limit → reject with
TOO_MANY_REQUESTS
Rate limit window duration in milliseconds.Validation:
- Must be a positive integer
- Coerced to number if provided as string
- Defines the sliding window for rate limiting
- Default: 5000ms (5 seconds)
- With default count of 4: users can send 4 messages per 5 seconds
- Can be overridden per channel with
CHAT_LIMITS_OVERRIDES
JSON object defining per-channel limit overrides.Format:Usage:Code reference:
- Override limits for specific channels (Roblox JobIds)
- All fields are optional (falls back to defaults)
- Parsed in
packages/api/src/config/chatLimits.ts
packages/api/src/config/chatLimits.ts
If JSON parsing fails, the server logs an error and uses default limits for all channels.
Environment Validation
The backend validates all environment variables on startup using Zod schemas defined inpackages/api/src/config/env.ts.
Validation Schema
packages/api/src/config/env.ts
Error Example
If validation fails, you’ll see:Example Configuration Files
Security Best Practices
Use Strong Random Secrets
Generate all secrets with cryptographically secure random generators:Never use predictable values like “secret123” or “password”.
Rotate Secrets Regularly
Plan to rotate secrets periodically:
- JWT_SECRET: Rotating invalidates all active sessions
- VERIFICATION_SECRET: Must update in both backend and Roblox game
Troubleshooting
Server exits immediately with validation errors
Server exits immediately with validation errors
Check the error message format:Fix the indicated variables and restart.
JWT_SECRET too short/long
JWT_SECRET too short/long
Must be exactly 32-64 characters:
VERIFICATION_SECRET too short
VERIFICATION_SECRET too short
Must be at least 64 characters:
VERIFICATION_PLACE_ID invalid
VERIFICATION_PLACE_ID invalid
Must be numeric only (no spaces, letters, or special characters):
CHAT_LIMITS_OVERRIDES not working
CHAT_LIMITS_OVERRIDES not working
Ensure valid JSON format:Check server logs for JSON parsing errors.
Next Steps
Server Setup
Set up and run the backend server
Game Integration
Integrate with your Roblox game