RAILWAY VARIABLES GUIDE

Documentation management API with real-time MongoDB sync

🔧 Railway Environment Variables for backend-docs-api

Required Variables Checklist

Here's exactly what you need to add in Railway for the "Docs-api" service:

✅ Variables to COPY from backend-api

Open your backend-api Railway service and copy these:

Variable Copy From Why
JWT_SECRET backend-api MUST match for shared authentication
SYSTEM_TOKEN backend-api MUST match for internal service calls

How to copy:

  1. Open backend-api service in Railway
  2. Click "Variables" tab
  3. Copy the values
  4. Paste into Docs-api service

📝 New Variables to ADD

These are specific to backend-docs-api:

Variable Value Notes
MONGODB_CONNECTION_STRING_TEST_MODULES mongodb+srv://... Your test-modules cluster URI (from .env.local)
ALLOWED_ORIGINS https://gograb.space,http://localhost:5010 For CORS
NODE_ENV production Standard

🤖 Railway Auto-Generated (Don't Add)

Railway automatically provides:


Copy-Paste Ready Format

Option 1: Add One by One

Click "+ New Variable" in Railway and paste each:

Variable: JWT_SECRET
Value: <copy-from-backend-api>

Variable: SYSTEM_TOKEN
Value: <copy-from-backend-api>

Variable: MONGODB_CONNECTION_STRING_TEST_MODULES
Value: <copy-from-your-env-local>

Variable: ALLOWED_ORIGINS
Value: https://gograb.space,http://localhost:5010

Variable: NODE_ENV
Value: production

Option 2: Use Raw Editor

Click "Raw Editor" in Railway Variables tab and paste:

JWT_SECRET=<copy-from-backend-api>
SYSTEM_TOKEN=<copy-from-backend-api>
MONGODB_CONNECTION_STRING_TEST_MODULES=<copy-from-your-env-local>
ALLOWED_ORIGINS=https://gograb.space,http://localhost:5010
NODE_ENV=production

Where to Find Values

JWT_SECRET

Location: Your backend-api Railway service → Variables tab

It looks like: A long random string (base64), e.g., <YOUR_JWT_SECRET_FROM_ENV_LOCAL>

Critical: This MUST be identical to backend-api for shared auth to work!

SYSTEM_TOKEN

Location: Your backend-api Railway service → Variables tab

It looks like: Another long random string

Critical: This MUST match for internal service communication!

MONGODB_CONNECTION_STRING_TEST_MODULES

Location: Your .env.local file in the project

It looks like: mongodb+srv://username:[email protected]/

Note: This is your test-modules cluster, NOT your main production cluster


Verification

After adding variables, check:

  1. Count: You should have 5 variables in "Service Variables"
  2. Railway Auto: Plus 6 variables added by Railway
  3. Total: 11 variables total

Quick Check Script

Run this locally to see your variables:

# Check what's in your .env.local
grep -E "JWT_SECRET|SYSTEM_TOKEN|MONGODB_CONNECTION_STRING_TEST_MODULES" .env.local

What Happens if Variables are Wrong?

Missing/Wrong Variable Result
JWT_SECRET doesn't match Authentication fails between APIs
SYSTEM_TOKEN doesn't match File watcher can't sync to API
MONGODB_CONNECTION_STRING_TEST_MODULES wrong Can't connect to database, app crashes
ALLOWED_ORIGINS missing CORS errors from frontend
NODE_ENV missing App runs in dev mode (not critical but suboptimal)

Ready to Add Variables?

Go to: Railway Docs-api service → Variables tab → Click "+ New Variable"

Then add the 5 variables listed above!

After adding: Click "Deploy" button (top right) to restart with new variables.