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.
This commit is contained in:
Ian Troisi committed 2026-06-11 13:43:19 -04:00
1 parent 120708ed47
commit 8af13b04ec
1 file changed
+19 -2
+19 -2
View File
@@ -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<StatusPage, "url" | "customDomain">
): 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<StatusPage, "url" | "customDomain">
): string => {
if (statusPage.customDomain) {
return `https://${statusPage.customDomain}`;
return buildCustomDomainOrigin(statusPage.customDomain);
}
if (typeof window !== "undefined") {