From 0917bb7a0febc3145c30f05faff109b009825dab Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Wed, 18 Jun 2025 16:42:50 -0400 Subject: [PATCH] use env vars manually to instantiate redis --- src/atproto-oauth.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/atproto-oauth.ts b/src/atproto-oauth.ts index 3644da53..d8b84fbf 100644 --- a/src/atproto-oauth.ts +++ b/src/atproto-oauth.ts @@ -19,8 +19,15 @@ export async function createOauthClient() { ]) : undefined; let requestLock: RuntimeLock | undefined; - if (process.env.NODE_ENV === "production") { - const redis = Redis.fromEnv(); + if ( + process.env.NODE_ENV === "production" && + process.env.KV_REST_API_URL && + process.env.KV_REST_API_TOKEN + ) { + const redis = new Redis({ + url: process.env.KV_REST_API_URL, + token: process.env.KV_REST_API_TOKEN, + }); const redlock = new Redlock([redis]); requestLock = async (key, fn) => { // 30 seconds should be enough. Since we will be using one lock per user id -- 2.54.0