diff --git a/README.md b/README.md index 16c37d60..7109ff8e 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ _⚠️ READ BEFORE PROCEEDING_ - Generate an API key and store in environment variable `OPENAI_SECRET_KEY` (make sure to enable Responses API write access if customizing permissions) - Setup usage limits to avoid unexpected charges (_recommended_) 2. Add rate limiting (_recommended_) - - As an additional precaution, create an Upstash Redis store from the storage tab of the Vercel dashboard and link it to your project in order to enable rate limiting—no further configuration necessary + - As an additional precaution, create an Upstash Redis store from the storage tab of the Vercel dashboard and link it to your project (if you are required to add an environment variable prefix, use `EXIF`) in order to enable rate limiting—no further configuration necessary 3. Configure auto-generated fields (optional) - Set which text fields auto-generate when uploading a photo by storing a comma-separated list, e.g., `AI_TEXT_AUTO_GENERATED_FIELDS = title,semantic` - Accepted values: diff --git a/src/app/config.ts b/src/app/config.ts index 2e1d82b9..18f89989 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -160,7 +160,11 @@ export const POSTGRES_SSL_ENABLED = // STORAGE: REDIS export const HAS_REDIS_STORAGE = - Boolean(process.env.KV_URL); + Boolean( + process.env.KV_URL || + process.env.EXIF_KV_URL || + process.env.UPSTASH_REDIS_REST_URL, + ); // STORAGE: VERCEL BLOB export const HAS_VERCEL_BLOB_STORAGE = diff --git a/src/platforms/redis.ts b/src/platforms/redis.ts index 282ae75e..8182c2b0 100644 --- a/src/platforms/redis.ts +++ b/src/platforms/redis.ts @@ -1,9 +1,18 @@ import { Redis } from '@upstash/redis'; -import { HAS_REDIS_STORAGE } from '@/app/config'; const KEY_TEST = 'test'; -export const redis = HAS_REDIS_STORAGE ? Redis.fromEnv() : undefined; +export const redis = + process.env.KV_URL || + process.env.UPSTASH_REDIS_REST_URL + ? Redis.fromEnv() + : process.env.EXIF_KV_URL && + process.env.EXIF_KV_REST_API_TOKEN + ? new Redis({ + url: process.env.EXIF_KV_URL, + token: process.env.EXIF_KV_REST_API_TOKEN, + }) + : undefined; export const warmRedisConnection = () => { if (redis) { redis.get(KEY_TEST); }