feat: custom domain setting check

This commit is contained in:
DIYgod
2022-08-17 02:56:16 +01:00
parent a23536bdda
commit bda2fc36c8
+8 -1
View File
@@ -1,4 +1,5 @@
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")
@@ -30,7 +31,13 @@ export const getTenant = async (request: Request, search: URLSearchParams) => {
},
)
const txt = await res.json()
return txt?.Answer?.[0]?.data.replace(/^"|"$/g, "")
const tenant = txt?.Answer?.[0]?.data.replace(/^"|"$/g, "")
if (tenant) {
const site = await getSite(tenant)
if (site.custom_domain === host) {
return tenant
}
}
}
}
return