♻️ refactor(redis): disable automatic deserialization in upstash provider (#11210)

This commit is contained in:
YuTengjing
2026-01-05 11:32:41 +08:00
committed by GitHub
parent 41b710950c
commit eb5c76ca4b
3 changed files with 7 additions and 7 deletions

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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);
}
/**