Skip to content

Open-source status page, incident response and uptime monitoring

wip: ffs

Maximilian Kaske3bbeda23b213
diff --git a/apps/status-page/next.config.ts b/apps/status-page/next.config.ts
index f8cde4e8a..d99e79a9e 100644
--- a/apps/status-page/next.config.ts
+++ b/apps/status-page/next.config.ts
@@ -12,41 +12,41 @@ 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",
- // },
- // ],
- // missing: [
- // // Skip this rewrite when the request came via proxy from web app
- // {
- // type: "header",
- // key: "x-proxy",
- // value: "1",
- // },
- // {
- // type: "host",
- // value:
- // process.env.NODE_ENV === "production"
- // ? "www\\.stpg\\.dev"
- // : "www\\.localhost",
- // },
- // ],
- // destination: "/:subdomain/:path*",
- // },
- // ],
- // };
- // },
+ 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",
+ },
+ ],
+ missing: [
+ // Skip this rewrite when the request came via proxy from web app
+ {
+ type: "header",
+ key: "x-proxy",
+ value: "1",
+ },
+ {
+ type: "host",
+ value:
+ process.env.NODE_ENV === "production"
+ ? "www\\.stpg\\.dev"
+ : "www\\.localhost",
+ },
+ ],
+ destination: "/:subdomain/:path*",
+ },
+ ],
+ };
+ },
};
export default nextConfig;
diff --git a/apps/status-page/src/middleware.ts b/apps/status-page/src/middleware.ts
index fad7bf6aa..6890fbfb6 100644
--- a/apps/status-page/src/middleware.ts
+++ b/apps/status-page/src/middleware.ts
@@ -84,6 +84,12 @@ export default async function middleware(req: NextRequest) {
return NextResponse.rewrite(new URL(`/${prefix}${url.pathname}`, req.url));
}
+ if (_page.customDomain === prefix && pathnames[1] === pathnames[2]) {
+ // WTF is this
+ const newPathname = `/${pathnames.slice(2).join("/")}`;
+ return NextResponse.rewrite(new URL(newPathname, req.url));
+ }
+
return response;
}