Fix maintenance redirects and admin host detection
This commit is contained in:
+14
-6
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user