RAILWAY VARIABLES CORRECTIONS
Documentation management API with real-time MongoDB sync
✅ Railway Variables Review for backend-docs-api
Your Current Variables - Review
✅ CORRECT (Keep These)
# 🔒 Get these values from your .env.local file
MONGODB_CONNECTION_STRING_TEST_MODULES="<YOUR_MONGODB_CONNECTION_STRING>"
JWT_SECRET="<YOUR_JWT_SECRET>"
NODE_ENV="production"
✅ These are exactly what backend-docs-api needs. Get actual values from .env.local.
❌ MISSING (Need to Add)
SYSTEM_TOKEN=<copy-from-backend-api-Railway-variables>
Action: Go to backend-api Railway service → Variables → Copy SYSTEM_TOKEN value → Add to Docs-api
⚠️ NEEDS UPDATE
# Current (WRONG for production):
ALLOWED_ORIGINS="http://localhost:5701,http://localhost:5200,http://localhost:4200,http://localhost:5300"
# Should be (for backend-docs-api):
ALLOWED_ORIGINS="https://gograb.space,http://localhost:5010"
Why:
https://gograb.space- Your production frontend domainhttp://localhost:5010- docs-angular local dev
Action: Update ALLOWED_ORIGINS variable in Railway
❌ NOT NEEDED (Remove or Ignore)
These are NOT used by backend-docs-api:
MONGODB_CONNECTION_STRING="..." # ❌ This is for backend-api only
MONGODB_DATABASE="gograb-api" # ❌ This is for backend-api only
MONGODB_TEST_MODULES_DATABASE="docs" # ❌ Not needed (we set dbName in code as 'docs-database')
JWT_EXPIRATION="7d" # ❌ Not needed (set in code)
OPENAI_API_KEY="..." # ❌ Not needed for docs-api
ANTHROPIC_API_KEY="..." # ❌ Not needed for docs-api
GOOGLE_API_KEY="..." # ❌ Not needed for docs-api
Action: Remove these from Docs-api service (they won't hurt, but they're unnecessary)
Final Configuration for Docs-api
Your Railway "Docs-api" service should have ONLY these 5 variables:
# 1. MongoDB Connection (test-modules cluster)
# 🔒 Get from: .env.local or MongoDB Atlas Dashboard
MONGODB_CONNECTION_STRING_TEST_MODULES="<YOUR_MONGODB_CONNECTION_STRING>"
# 2. Shared Authentication (MUST match backend-api)
# 🔒 Get from: .env.local file
JWT_SECRET="<YOUR_JWT_SECRET>"
SYSTEM_TOKEN="<YOUR_SYSTEM_TOKEN>"
# 3. CORS Configuration
ALLOWED_ORIGINS="https://gograb.space,http://localhost:5010"
# 4. Environment
NODE_ENV="production"
Why Two MongoDB Clusters?
You have the setup correct:
Main Cluster (gograbspace.dgajj2t.mongodb.net)
- Used by: backend-api
- Database: gograb-api
- Contains: Users, spaces, universes, etc.
- Variable:
MONGODB_CONNECTION_STRING
Test Modules Cluster (test-modules.7hkxufn.mongodb.net)
- Used by: backend-docs-api
- Database: docs-database
- Contains: Documentation files, analytics
- Variable:
MONGODB_CONNECTION_STRING_TEST_MODULES
This separation is correct - it isolates documentation from production data! ✅
Database Name Clarification
You don't need MONGODB_TEST_MODULES_DATABASE variable because:
// In app.module.ts, we hardcode the database name:
createMongooseConfig(configService, {
dbName: 'docs-database', // ← Hardcoded in code
connectionStringKey: 'MONGODB_CONNECTION_STRING_TEST_MODULES',
})
MongoDB will automatically use the docs-database database within your test-modules cluster.
Action Items
- ✅ You have:
MONGODB_CONNECTION_STRING_TEST_MODULES - ✅ You have:
JWT_SECRET - ✅ You have:
NODE_ENV - ❌ ADD:
SYSTEM_TOKEN(copy from backend-api) - ⚠️ UPDATE:
ALLOWED_ORIGINSto"https://gograb.space,http://localhost:5010"
Quick Fix in Railway
- Click "+ New Variable"
- Add
SYSTEM_TOKEN→ Value from backend-api - Click on
ALLOWED_ORIGINSvariable - Update to:
https://gograb.space,http://localhost:5010 - Click "Deploy" (top right)
Then you're ready to go! 🚀