From 93d2245a97c31268808ce394ee1d8cbf0b7bfbaa Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Tue, 17 Mar 2026 17:02:42 -0700 Subject: [PATCH] fix(web): exclude PostHog proxy from i18n middleware (#1626) * fix(web): exclude PostHog proxy path from i18n middleware The next-intl middleware added in cf75da8f intercepts /cmuxterm/* requests (the PostHog reverse proxy), causing analytics to break since March 12. Add cmuxterm to the negative lookahead so proxy requests bypass i18n. * refactor(web): rename middleware.ts to proxy.ts for Next.js 16 Next.js 16 renamed middleware.ts to proxy.ts. Migrate to the new convention since we're on Next.js 16.1.6. * feat(web): migrate PostHog to managed reverse proxy at r.cmux.dev Replace the Next.js rewrites-based proxy (/cmuxterm -> us.i.posthog.com) with PostHog's managed reverse proxy at r.cmux.dev. This removes the rewrites from next.config.ts entirely and eliminates the proxy.ts matcher conflict that caused the analytics regression. --------- Co-authored-by: Lawrence Chen --- web/app/[locale]/posthog.tsx | 2 +- web/next.config.ts | 12 ------------ web/{middleware.ts => proxy.ts} | 0 3 files changed, 1 insertion(+), 13 deletions(-) rename web/{middleware.ts => proxy.ts} (100%) diff --git a/web/app/[locale]/posthog.tsx b/web/app/[locale]/posthog.tsx index 33d46c48..8c924c3c 100644 --- a/web/app/[locale]/posthog.tsx +++ b/web/app/[locale]/posthog.tsx @@ -7,7 +7,7 @@ import { useEffect, Suspense } from "react"; if (typeof window !== "undefined") { posthog.init("phc_opOVu7oFzR9wD3I6ZahFGOV2h3mqGpl5EHyQvmHciDP", { - api_host: "/cmuxterm", + api_host: "https://r.cmux.dev", ui_host: "https://us.posthog.com", person_profiles: "identified_only", capture_pageview: false, diff --git a/web/next.config.ts b/web/next.config.ts index 1c25cf3d..3ab0db0d 100644 --- a/web/next.config.ts +++ b/web/next.config.ts @@ -15,18 +15,6 @@ const nextConfig: NextConfig = { }, ], }, - async rewrites() { - return [ - { - source: "/cmuxterm/static/:path*", - destination: "https://us-assets.i.posthog.com/static/:path*", - }, - { - source: "/cmuxterm/:path*", - destination: "https://us.i.posthog.com/:path*", - }, - ]; - }, }; export default withNextIntl(nextConfig); diff --git a/web/middleware.ts b/web/proxy.ts similarity index 100% rename from web/middleware.ts rename to web/proxy.ts