Skip to content

Commit 5632662

Browse files
authored
repo sync
2 parents e8ae95f + e94b52d commit 5632662

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

lib/redis-accessor.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ class RedisAccessor {
2626
? new Redis(REDIS_URL, {
2727
...redisBaseOptions,
2828
db: databaseNumber,
29-
tls: {
30-
// Required for production Heroku Redis
31-
rejectUnauthorized: false
29+
30+
// Only add this configuration for TLS-enabled REDIS_URL values.
31+
// Otherwise, it breaks for local Redis instances without TLS enabled.
32+
...REDIS_URL.startsWith('rediss://') && {
33+
tls: {
34+
// Required for production Heroku Redis
35+
rejectUnauthorized: false
36+
}
3237
}
3338
})
3439
: new InMemoryRedis()

middleware/rate-limit.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ module.exports = rateLimit({
1919
store: REDIS_URL && new RedisStore({
2020
client: new Redis(REDIS_URL, {
2121
db: rateLimitDatabaseNumber,
22-
tls: {
23-
// Required for production Heroku Redis
24-
rejectUnauthorized: false
22+
23+
// Only add this configuration for TLS-enabled REDIS_URL values.
24+
// Otherwise, it breaks for local Redis instances without TLS enabled.
25+
...REDIS_URL.startsWith('rediss://') && {
26+
tls: {
27+
// Required for production Heroku Redis
28+
rejectUnauthorized: false
29+
}
2530
}
2631
}),
2732
// 1 minute (or practically unlimited outside of production)

script/purge-redis-pages.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ purgeRenderedPageCache()
4444
function purgeRenderedPageCache () {
4545
const redisClient = new Redis(REDIS_URL, {
4646
db: pageCacheDatabaseNumber,
47-
tls: {
48-
// Required for production Heroku Redis
49-
rejectUnauthorized: false
47+
48+
// Only add this configuration for TLS-enabled REDIS_URL values.
49+
// Otherwise, it breaks for local Redis instances without TLS enabled.
50+
...REDIS_URL.startsWith('rediss://') && {
51+
tls: {
52+
// Required for production Heroku Redis
53+
rejectUnauthorized: false
54+
}
5055
}
5156
})
5257
let totalKeyCount = 0

0 commit comments

Comments
 (0)