diff --git a/packages/frontend-2/plugins/004-redis.server.ts b/packages/frontend-2/plugins/004-redis.server.ts index 06ba3797a4..ecb34b4107 100644 --- a/packages/frontend-2/plugins/004-redis.server.ts +++ b/packages/frontend-2/plugins/004-redis.server.ts @@ -12,26 +12,28 @@ export default defineNuxtPlugin(async () => { const { redisUrl } = useRuntimeConfig() const logger = useLogger() - try { - const hasValidStatus = - redis && ['ready', 'connecting', 'reconnecting'].includes(redis.status) - if (!redis || !hasValidStatus) { - if (redis) { - await redis.quit() - } + if (redisUrl?.length) { + try { + const hasValidStatus = + redis && ['ready', 'connecting', 'reconnecting'].includes(redis.status) + if (!redis || !hasValidStatus) { + if (redis) { + await redis.quit() + } - redis = new Redis(redisUrl) + redis = new Redis(redisUrl) - redis.on('error', (err) => { - logger.error(err, 'Redis error') - }) + redis.on('error', (err) => { + logger.error(err, 'Redis error') + }) - redis.on('end', () => { - logger.info('Redis disconnected from server') - }) + redis.on('end', () => { + logger.info('Redis disconnected from server') + }) + } + } catch (e) { + logger.error(e, 'Redis setup failure') } - } catch (e) { - logger.error(e, 'Redis setup failure') } const isValid = redis && redis.status === 'ready'