mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Docker images launched without a sibling Redis container used to spam '[REDIS] Error: connect ECONNREFUSED 127.0.0.1:6379' for every rate-limit and API-key-auth cache lookup. The root cause was a default of process.env.REDIS_URL || 'redis://localhost:6379' that turned the opt-in cache into a hard dependency. Three coordinated changes: 1. src/shared/utils/rateLimiter.ts — gate Redis on REDIS_URL being explicitly set. getRedisClient() returns null when disabled; the single connection-error handler dedupes via a redisErrorLogged latch so a sustained outage produces one warn instead of per-request flood. checkRateLimit() routes to the existing in-memory store on both the 'disabled' and 'test' paths. 2. src/lib/db/apiKeys.ts — short-circuit Redis-backed auth cache reads and writes when getRedisClient() returns null. SQLite remains authoritative; the cache is purely an optimization. 3. Same file — replace the wildcard scope matcher's dynamic RegExp compilation with a deterministic segment walker. Eliminates the ReDoS surface on operator-supplied scope patterns and silences the Semgrep js/regex-injection advisory that previously blocked edits to this file. Single-instance deployments now work silently out of the box; multi-instance setups continue to use Redis when REDIS_URL is set.