Fix maintenance redirects and admin host detection

This commit is contained in:
MOH
2026-03-15 04:33:07 +01:00
parent 5d3f77962a
commit 50c3f5cce9
4 changed files with 91 additions and 18 deletions
+14 -6
View File
@@ -43,12 +43,20 @@ export function getSiteHost(): string {
return parseHostname(process.env.NEXT_PUBLIC_SITE_URL ?? DEFAULT_SITE_URL) ?? "localhost";
}
export function getRequestHostname(hostHeader?: string | null): string {
return (hostHeader ?? "")
.split(",")[0]
?.trim()
.toLowerCase()
.replace(/:\d+$/, "") ?? "";
export function getRequestHostname(...hostHeaders: Array<string | null | undefined>): string {
for (const hostHeader of hostHeaders) {
const normalizedHostname = (hostHeader ?? "")
.split(",")[0]
?.trim()
.toLowerCase()
.replace(/:\d+$/, "") ?? "";
if (normalizedHostname) {
return normalizedHostname;
}
}
return "";
}
export function isAdminHost(hostname: string): boolean {