Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
fix: custom domain resolution for self-hosted instances (#2019)
Rayan Salhabaae2864d4c70
diff --git a/apps/status-page/src/proxy.ts b/apps/status-page/src/proxy.tsindex 5c43617d0..ae1a10dbc 100644--- a/apps/status-page/src/proxy.ts+++ b/apps/status-page/src/proxy.ts@@ -9,6 +9,8 @@ import { getValidSubdomain } from "./lib/domain";import { createProtectedCookieKey } from "./lib/protected";import { resolveRoute } from "./lib/resolve-route";+const isSelfHosted = process.env.SELF_HOST === "true";+function isIpAllowed(ip: string, allowedRanges: string[]): boolean {// No ranges configured — deny all (defensive: form validation prevents this)if (allowedRanges.length === 0) return false;@@ -104,7 +106,11 @@ export default auth(async (req) => {const { pathname, origin } = req.nextUrl;// custom domain redirect- if (_page.customDomain && host !== `${_page.slug}.stpg.dev`) {+ if (+ !isSelfHosted &&+ _page.customDomain &&+ host !== `${_page.slug}.stpg.dev`+ ) {const redirect = pathname.replace(`/${_page.customDomain}`, "");const url = new URL(`https://${_page.customDomain}/login?redirect=${encodeURIComponent(@@ -126,7 +132,11 @@ export default auth(async (req) => {const redirect = url.searchParams.get("redirect");// custom domain redirect- if (_page.customDomain && host !== `${_page.slug}.stpg.dev`) {+ if (+ !isSelfHosted &&+ _page.customDomain &&+ host !== `${_page.slug}.stpg.dev`+ ) {const url = new URL(`https://${_page.customDomain}${redirect ?? "/"}`);console.log("redirect to /", url.toString());return NextResponse.redirect(url);@@ -206,10 +216,17 @@ export default auth(async (req) => {console.log({customDomain: _page.customDomain,host,- expectedHost: `${_page.slug}.stpg.dev`,+ expectedHost: isSelfHosted+ ? "(self-hosted mode)"+ : `${_page.slug}.stpg.dev`,});- if (_page.customDomain && host !== `${_page.slug}.stpg.dev`) {+ // stpg.dev-specific rewrite — skipped in self-hosted deployments+ if (+ !isSelfHosted &&+ _page.customDomain &&+ host !== `${_page.slug}.stpg.dev`+ ) {const pathnames = url.pathname.split("/");const subdomain = getValidSubdomain(url.host);if (pathnames.length > 2 && !subdomain) {