Skip to content

Open-source status page, incident response and uptime monitoring

chore: subdomain rewrites (#1355)

Maximilian Kaske2e333cffbdf4
diff --git a/apps/status-page/next.config.ts b/apps/status-page/next.config.ts
index 113a50310..35afd3b9d 100644
--- a/apps/status-page/next.config.ts
+++ b/apps/status-page/next.config.ts
@@ -12,6 +12,26 @@ const nextConfig: NextConfig = {
fullUrl: true,
},
},
+ async rewrites() {
+ return {
+ beforeFiles: [
+ {
+ source:
+ "/:path((?!api|assets|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
+ has: [
+ {
+ type: "host",
+ value:
+ process.env.NODE_ENV === "production"
+ ? "(?<subdomain>[^.]+)\\.stpg\\.dev"
+ : "(?<subdomain>[^.]+)\\.localhost",
+ },
+ ],
+ destination: "/:subdomain/:path*",
+ },
+ ],
+ };
+ },
};
export default nextConfig;
diff --git a/apps/status-page/src/middleware.ts b/apps/status-page/src/middleware.ts
index 32b53a9ed..d07dcd94b 100644
--- a/apps/status-page/src/middleware.ts
+++ b/apps/status-page/src/middleware.ts
@@ -26,7 +26,7 @@ export default async function middleware(req: NextRequest) {
type = "pathname";
}
- if (url.pathname === "/") {
+ if (url.pathname === "/" && type !== "hostname") {
return response;
}