fix: custom domain setting check

This commit is contained in:
DIYgod
2022-08-17 03:13:14 +01:00
parent bb505b6c5e
commit d7d85e06df
+9 -3
View File
@@ -1,5 +1,4 @@
import { OUR_DOMAIN } from "./env"
import { getSite } from "~/models/site.model"
export const getTenant = async (request: Request, search: URLSearchParams) => {
const host = request.headers.get("host")
@@ -33,8 +32,15 @@ export const getTenant = async (request: Request, search: URLSearchParams) => {
const txt = await res.json()
const tenant = txt?.Answer?.[0]?.data.replace(/^"|"$/g, "")
if (tenant) {
const site = await getSite(tenant)
if (site.custom_domain === host) {
const res = await fetch(
`https://indexer.crossbell.io/v1/handles/${tenant}/character`,
)
const char = await res.json()
const customDomain =
char?.metadata?.content?.attributes?.find(
(a: any) => a.trait_type === "xlog_custom_domain",
)?.value || ""
if (customDomain && customDomain === host) {
return tenant
}
}