fix(redis): skip missing-REDIS_URL warning during production build
This commit is contained in:
1 parent
8d3263a8fe
commit
ef0c425598
1 file changed
+6
-1
+6
-1
@@ -1,3 +1,4 @@
|
||||
import { PHASE_PRODUCTION_BUILD } from "next/constants";
|
||||
import "server-only";
|
||||
|
||||
import Redis from "ioredis";
|
||||
@@ -12,7 +13,11 @@ const globalForRedis = globalThis as unknown as {
|
||||
function createRedis(): Redis | null {
|
||||
const url = env.REDIS_URL;
|
||||
if (!url) {
|
||||
if (env.NODE_ENV === "production" && !globalForRedis.redisMissingWarned) {
|
||||
if (
|
||||
env.NODE_ENV === "production" &&
|
||||
process.env.NEXT_PHASE !== PHASE_PRODUCTION_BUILD &&
|
||||
!globalForRedis.redisMissingWarned
|
||||
) {
|
||||
globalForRedis.redisMissingWarned = true;
|
||||
logger.error(
|
||||
"[redis] REDIS_URL is unset in production. Rate limits, site-settings cache, and JWT session invalidation fall back to in-process memory and will not work correctly across multiple instances or restarts. Set REDIS_URL in .env.",
|
||||
|
||||
Reference in new issue
Block a user