From d2ce8882d0e27e53fc33e17f4c0af0631cfeee56 Mon Sep 17 00:00:00 2001 From: Nick Playfair Date: Thu, 12 Aug 2021 00:40:55 +0100 Subject: [PATCH] Use redis url env var on production --- index.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index cff0cb3..b960327 100644 --- a/index.js +++ b/index.js @@ -4,11 +4,19 @@ const redis = require('redis'); const cors = require('cors'); require('dotenv').config(); const app = express(); -const redisConfig = { - host: process.env.REDIS_HOST, - port: 6379, - db: 1, -}; + +if (process.env.NODE_ENV === 'production') { + const redisConfig = { + url: process.env.REDIS_URL, + db: 1, + } +} else { + const redisConfig = { + host: process.env.REDIS_HOST, + port: 6379, + db: 1, + }; +} const client = redis.createClient(redisConfig); client.on('error', (err) => {