mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
♻️ refactor(redis): disable automatic deserialization in upstash provider (#11210)
This commit is contained in:
@@ -43,8 +43,8 @@ export const GET = async (_req: Request, segmentData: { params: Params }) => {
|
||||
|
||||
const cacheKey = buildCacheKey(id);
|
||||
if (redisClient) {
|
||||
// Upstash Redis auto-deserializes JSON, so cached is already an object
|
||||
const cached = (await redisClient.get(cacheKey)) as CachedFileData | null;
|
||||
const cachedStr = await redisClient.get(cacheKey);
|
||||
const cached = cachedStr ? (JSON.parse(cachedStr) as CachedFileData) : null;
|
||||
if (cached?.redirectUrl) {
|
||||
log('Cache hit for file: %s', id);
|
||||
return Response.redirect(cached.redirectUrl, 302);
|
||||
|
||||
@@ -64,10 +64,7 @@ const enabledSSOProviders = parseSSOProviders(authEnv.AUTH_SSO_PROVIDERS);
|
||||
const { socialProviders, genericOAuthProviders } = initBetterAuthSSOProviders();
|
||||
|
||||
async function customEmailValidator(email: string): Promise<boolean> {
|
||||
if (ENABLE_BUSINESS_FEATURES && !(await businessEmailValidator(email))) {
|
||||
return false;
|
||||
}
|
||||
return validateEmail(email);
|
||||
return ENABLE_BUSINESS_FEATURES ? businessEmailValidator(email) : validateEmail(email);
|
||||
}
|
||||
|
||||
interface CustomBetterAuthOptions {
|
||||
|
||||
@@ -25,7 +25,10 @@ export class UpstashRedisProvider implements BaseRedisProvider {
|
||||
constructor(options: UpstashConfig | RedisConfigNodejs) {
|
||||
const { prefix, ...clientOptions } = options as UpstashConfig & RedisConfigNodejs;
|
||||
this.prefix = prefix ? `${prefix}:` : '';
|
||||
this.client = new Redis(clientOptions as RedisConfigNodejs);
|
||||
this.client = new Redis({
|
||||
...clientOptions,
|
||||
automaticDeserialization: false,
|
||||
} as RedisConfigNodejs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user