Skip to content

Commit 64347a8

Browse files
ssk42claude
andcommitted
fix: add SSL cert validation bypass for Heroku Redis cache
Heroku Redis uses self-signed certificates. The rate limiter already had this fix, but the cache Redis URL was missing it, causing 500 errors on all cached routes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ebce0b9 commit 64347a8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

config.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,24 @@ def get_database_uri():
6060

6161
# Caching (Item 12)
6262
CACHE_TYPE = 'RedisCache' if os.getenv('REDIS_URL') else 'SimpleCache'
63-
CACHE_REDIS_URL = os.getenv('REDIS_URL')
6463
CACHE_DEFAULT_TIMEOUT = 300
6564

65+
@staticmethod
66+
def get_cache_redis_url():
67+
"""Get cache Redis URL with SSL fix for Heroku."""
68+
uri = os.getenv('REDIS_URL')
69+
if not uri:
70+
return None
71+
# Heroku Redis uses self-signed certificates, so we must ignore validation
72+
if uri.startswith('rediss://') and 'ssl_cert_reqs' not in uri:
73+
if '?' in uri:
74+
uri += '&ssl_cert_reqs=none'
75+
else:
76+
uri += '?ssl_cert_reqs=none'
77+
return uri
78+
79+
CACHE_REDIS_URL = get_cache_redis_url.__func__()
80+
6681
# Rate Limiting
6782
@staticmethod
6883
def get_ratelimit_storage_uri():

0 commit comments

Comments
 (0)