fix: potentially unstable custom domain name dns

This commit is contained in:
DIYgod 2023-06-06 12:13:57 +01:00
parent c94b90bcb4
commit 3c163dff59
No known key found for this signature in database
2 changed files with 19 additions and 11 deletions

View File

@ -55,8 +55,10 @@ export async function GET(req: Request) {
}
} else {
const tenant = await fetchTenant(realHost, 5)
return {
subdomain: tenant,
if (tenant) {
return {
subdomain: tenant,
}
}
}
},

View File

@ -52,7 +52,9 @@ export async function cacheGet(options: {
if (!options.noUpdate) {
setTimeout(() => {
options.getValueFun().then((value) => {
redis.set(redisKey, JSON.stringify(value), "EX", REDIS_EXPIRE)
if (value) {
redis.set(redisKey, JSON.stringify(value), "EX", REDIS_EXPIRE)
}
})
}, Math.random() * REDIS_REFRESH)
}
@ -60,19 +62,23 @@ export async function cacheGet(options: {
} else {
if (options.allowEmpty) {
options.getValueFun().then(async (value) => {
if (options.noUpdate) {
await redis.set(redisKey, JSON.stringify(value))
} else {
redis.set(redisKey, JSON.stringify(value), "EX", REDIS_EXPIRE)
if (value) {
if (options.noUpdate) {
await redis.set(redisKey, JSON.stringify(value))
} else {
redis.set(redisKey, JSON.stringify(value), "EX", REDIS_EXPIRE)
}
}
})
return null
} else {
const value = await options.getValueFun()
if (options.noUpdate) {
await redis.set(redisKey, JSON.stringify(value))
} else {
redis.set(redisKey, JSON.stringify(value), "EX", REDIS_EXPIRE)
if (value) {
if (options.noUpdate) {
await redis.set(redisKey, JSON.stringify(value))
} else {
redis.set(redisKey, JSON.stringify(value), "EX", REDIS_EXPIRE)
}
}
return value
}