Store the serialized cookie jar in Upstash Redis after login and restore it on instance start, so serverless cold starts reuse the session instead of re-authenticating. Falls back to the previous in-memory behavior when Redis is not configured or unavailable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
11 lines
300 B
TypeScript
11 lines
300 B
TypeScript
import { Redis } from '@upstash/redis';
|
|
|
|
import { UPSTASH_REDIS_REST_TOKEN, UPSTASH_REDIS_REST_URL } from '@/env';
|
|
|
|
const redis =
|
|
UPSTASH_REDIS_REST_URL && UPSTASH_REDIS_REST_TOKEN
|
|
? new Redis({ url: UPSTASH_REDIS_REST_URL, token: UPSTASH_REDIS_REST_TOKEN })
|
|
: null;
|
|
|
|
export default redis;
|