Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
wtf: protected custom domain
Maximilian Kasked9bd759387ef
diff --git a/apps/status-page/src/middleware.ts b/apps/status-page/src/middleware.tsindex 0ee130cf0..c214e556e 100644--- a/apps/status-page/src/middleware.ts+++ b/apps/status-page/src/middleware.ts@@ -31,7 +31,7 @@ export default async function middleware(req: NextRequest) {type = "pathname";}- console.log({ pathname: url.pathname, type });+ console.log({ pathname: url.pathname, type, prefix });if (url.pathname === "/" && type !== "hostname") {return response;@@ -56,14 +56,19 @@ export default async function middleware(req: NextRequest) {if (_page?.passwordProtected) {const protectedCookie = cookies.get(createProtectedCookieKey(prefix));const password = protectedCookie ? protectedCookie.value : undefined;+ console.log({ protectedCookie, password });+if (password !== _page.password && !url.pathname.endsWith("/protected")) {const { pathname, origin } = req.nextUrl;// custom domain redirectif (_page.customDomain && host !== `${_page.slug}.stpg.dev`) {const newURL = new URL(`https://${_page.customDomain}`);- newURL.pathname = `/protected?redirect=${encodeURIComponent(pathname)}`;- console.log(newURL.toString());+ const newPathname = pathname.replace(`/${_page.customDomain}`, "");+ newURL.pathname = `/protected?redirect=${encodeURIComponent(+ newPathname,+ )}`;+ console.log("redirect to /protected", newURL.toString());return NextResponse.redirect(newURL);}@@ -80,8 +85,8 @@ export default async function middleware(req: NextRequest) {// custom domain redirectif (_page.customDomain && host !== `${_page.slug}.stpg.dev`) {const newURL = new URL(`https://${_page.customDomain}`);- newURL.pathname = redirect ?? type === "pathname" ? `/${prefix}` : "/";- console.log(newURL.toString());+ newURL.pathname = redirect ?? "/";+ console.log("redirect to /", newURL.toString());return NextResponse.redirect(newURL);}diff --git a/apps/web/next.config.js b/apps/web/next.config.jsindex 010d39ac6..95c40619c 100644--- a/apps/web/next.config.js+++ b/apps/web/next.config.js@@ -108,7 +108,7 @@ const nextConfig = {},{source:- "/:path((?!api|assets|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt|events|monitors).*)",+ "/:path((?!api|assets|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt|events|monitors|protected).*)",has: [{ type: "cookie", key: "sp_mode", value: "new" },{