From 8af13b04ecb4305ea11b37e42db649b262a664e5 Mon Sep 17 00:00:00 2001 From: Ian Troisi <56521951+Cincinnatus101010@users.noreply.github.com> Date: Thu, 11 Jun 2026 12:59:01 -0400 Subject: [PATCH] fix: derive custom domain URL protocol from client host Use the configured client host protocol instead of hardcoding https for custom domain status page links. --- client/src/Utils/statusPageUrl.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/client/src/Utils/statusPageUrl.ts b/client/src/Utils/statusPageUrl.ts index 9c898ee34..ff19f87c6 100644 --- a/client/src/Utils/statusPageUrl.ts +++ b/client/src/Utils/statusPageUrl.ts @@ -2,6 +2,23 @@ import { PUBLIC_STATUS_PAGE_PREFIX, type StatusPage } from "@/Types/StatusPage"; const CLIENT_HOST = import.meta.env.VITE_APP_CLIENT_HOST as string | undefined; +const getClientOriginProtocol = (): string => { + const source = + CLIENT_HOST || (typeof window !== "undefined" ? window.location.origin : undefined); + if (!source) { + return "https:"; + } + + try { + return new URL(source).protocol; + } catch { + return "https:"; + } +}; + +const buildCustomDomainOrigin = (customDomain: string): string => + `${getClientOriginProtocol()}//${customDomain}`; + export const getAppHostname = (): string | null => { const source = CLIENT_HOST || (typeof window !== "undefined" ? window.location.origin : undefined); @@ -33,7 +50,7 @@ export const getStatusPagePublicPath = ( statusPage: Pick ): string => { if (statusPage.customDomain) { - return `https://${statusPage.customDomain}`; + return buildCustomDomainOrigin(statusPage.customDomain); } return `${PUBLIC_STATUS_PAGE_PREFIX}/${statusPage.url}`; @@ -43,7 +60,7 @@ export const getStatusPagePublicUrl = ( statusPage: Pick ): string => { if (statusPage.customDomain) { - return `https://${statusPage.customDomain}`; + return buildCustomDomainOrigin(statusPage.customDomain); } if (typeof window !== "undefined") {