From 666fc5ad0e6990f79846bc5c29d4b1d02d1c804f Mon Sep 17 00:00:00 2001 From: JosueBrenes Date: Fri, 16 Jan 2026 10:53:35 -0600 Subject: [PATCH 1/2] feat: add middleware for subdomain redirection - Implemented middleware to redirect requests from the subdomain stats.acta.build to PostHog Shared with a 302 status. - Configured the middleware to execute on all routes. --- middleware.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 middleware.ts diff --git a/middleware.ts b/middleware.ts new file mode 100644 index 0000000..a187ae3 --- /dev/null +++ b/middleware.ts @@ -0,0 +1,23 @@ +import { NextResponse } from "next/server"; +import type { NextRequest } from "next/server"; + +export function middleware(request: NextRequest) { + const host = request.headers.get("host") || ""; + + // Detectar si el request viene del subdominio stats.acta.build + if (host === "stats.acta.build" || host.startsWith("stats.acta.build:")) { + // Redirigir a PostHog Shared con status 302 (temporal) + return NextResponse.redirect( + "https://us.posthog.com/shared/Hsleyk7g3zP5ny1eEoB4h0viBONr_w", + 302 + ); + } + + // Para todos los demás hosts (acta.build, etc.), continuar normalmente + return NextResponse.next(); +} + +// Configurar el matcher para que el middleware se ejecute en todas las rutas +export const config = { + matcher: "/:path*", +}; From aa8e33a96b77055de1374fd4f95b92d0c0a26266 Mon Sep 17 00:00:00 2001 From: JosueBrenes Date: Fri, 16 Jan 2026 10:55:05 -0600 Subject: [PATCH 2/2] refactor: clean up middleware comments and maintain functionality - Removed unnecessary comments in the middleware for clarity. - Kept the existing functionality for redirecting requests from the subdomain stats.acta.build to PostHog Shared. --- middleware.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/middleware.ts b/middleware.ts index a187ae3..fd05d74 100644 --- a/middleware.ts +++ b/middleware.ts @@ -4,20 +4,16 @@ import type { NextRequest } from "next/server"; export function middleware(request: NextRequest) { const host = request.headers.get("host") || ""; - // Detectar si el request viene del subdominio stats.acta.build if (host === "stats.acta.build" || host.startsWith("stats.acta.build:")) { - // Redirigir a PostHog Shared con status 302 (temporal) return NextResponse.redirect( "https://us.posthog.com/shared/Hsleyk7g3zP5ny1eEoB4h0viBONr_w", 302 ); } - // Para todos los demás hosts (acta.build, etc.), continuar normalmente return NextResponse.next(); } -// Configurar el matcher para que el middleware se ejecute en todas las rutas export const config = { matcher: "/:path*", };