Skip to content

Open-source status page, incident response and uptime monitoring

wtf: rewrite

Maximilian Kaskea3bf3a7077cb
diff --git a/apps/status-page/src/middleware.ts b/apps/status-page/src/middleware.ts
index 6890fbfb6..3f91ea615 100644
--- a/apps/status-page/src/middleware.ts
+++ b/apps/status-page/src/middleware.ts
@@ -84,8 +84,24 @@ export default async function middleware(req: NextRequest) {
return NextResponse.rewrite(new URL(`/${prefix}${url.pathname}`, req.url));
}
+ // NOTE - WORKING ON CUSTOM DOMAIN!!!
+
+ // WTF is this
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));
+ }
+
+ // WTF is this
+ if (
+ _page.customDomain === prefix &&
+ (pathnames[2] === "assets" ||
+ pathnames[2] === "api" ||
+ pathnames[2] === "_next" ||
+ pathnames[2] === "favicon.ico" ||
+ pathnames[2] === "robots.txt" ||
+ pathnames[2] === "sitemap.xml")
+ ) {
const newPathname = `/${pathnames.slice(2).join("/")}`;
return NextResponse.rewrite(new URL(newPathname, req.url));
}
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index 6ac7bf4c8..cd63d9df7 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -93,31 +93,6 @@ const nextConfig = {
],
destination: "https://:slug.stpg.dev/:path*",
},
- // Custom domains: pass through static assets and API routes without domain prefix
- {
- source: "/_next/:path*",
- has: [
- { type: "cookie", key: "sp_mode", value: "new" },
- {
- type: "host",
- value:
- "^(?!.*\\.openstatus\\.dev$)(?!openstatus\\.dev$)(?<domain>.+)$",
- },
- ],
- destination: "https://www.stpg.dev/_next/:path*",
- },
- {
- source: "/api/:path*",
- has: [
- { type: "cookie", key: "sp_mode", value: "new" },
- {
- type: "host",
- value:
- "^(?!.*\\.openstatus\\.dev$)(?!openstatus\\.dev$)(?<domain>.+)$",
- },
- ],
- destination: "https://www.stpg.dev/api/:path*",
- },
// Handle custom domains (e.g., status.mxkaske.dev)
{
source: "/:path*",
@@ -163,5 +138,5 @@ module.exports = withSentryConfig(
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
- }
+ },
);