Skip to content

Configuration

FlexGate is configured via config/flexgate.json and environment variables.
Run flexgate init to generate a starter config file.


Environment Variables

VariableDefaultDescription
PORT3001API gateway port
ADMIN_UI_PORT3000Admin UI port
DATABASE_URLPostgreSQL connection string
REDIS_URLredis://localhost:6379Redis URL (optional)
NATS_URLnats://localhost:4222NATS URL (optional)
ALLOWED_ORIGINShttp://localhost:3000,...Comma-separated CORS allowlist
NODE_ENVdevelopmentdevelopment | production
LOG_LEVELinfodebug | info | warn | error
ANTHROPIC_API_KEYClaude API key for AI features

💡 Tip: Copy .env.example to .env and fill in your values:

bash
cp .env.example .env

Config File Reference (config/flexgate.json)

json
{
  "proxy": {
    "port": 3001,
    "maxBodySize": "10mb",
    "trustProxy": true
  },
  "upstreams": [
    {
      "name": "my-api",
      "url": "http://localhost:8080",
      "timeout": 30000,
      "healthCheck": {
        "path": "/health",
        "interval": 30000
      }
    }
  ],
  "routes": [
    {
      "path": "/api/v1/*",
      "upstream": "my-api",
      "methods": ["GET", "POST", "PUT", "DELETE"],
      "rateLimit": {
        "windowMs": 60000,
        "max": 100
      }
    }
  ],
  "database": {
    "url": "${DATABASE_URL}",
    "pool": { "min": 2, "max": 10 }
  },
  "redis": {
    "url": "${REDIS_URL}"
  },
  "timeouts": {
    "request": 30000,
    "upstream": 25000
  }
}

CORS Configuration

Set allowed origins via the ALLOWED_ORIGINS environment variable:

Development:

bash
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001

Production:

bash
ALLOWED_ORIGINS=https://app.yourdomain.com,https://admin.yourdomain.com

⚠️ Warning: Do not leave ALLOWED_ORIGINS unset in production — it defaults to localhost origins only.


Rate Limiting Tiers

TierApplies toLimit
globalApiRateLimiterAll /api/*100 req / min
adminApiRateLimiterRoutes, settings, webhooks, AI, logs60 req / min
authRateLimiter/api/auth5 req / 15 min

Released under the MIT License.