From 57ade6f1b487564f52ae3a946fe2f084270cba41 Mon Sep 17 00:00:00 2001 From: Andrew Jiang <andrew@buildwithfern.com> Date: Fri, 13 Sep 2024 00:41:20 +1000 Subject: [PATCH] fix: posthog rewrite (#1459) --- packages/ui/docs-bundle/src/middleware.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ui/docs-bundle/src/middleware.ts b/packages/ui/docs-bundle/src/middleware.ts index adfd7eda55..e6452495ca 100644 --- a/packages/ui/docs-bundle/src/middleware.ts +++ b/packages/ui/docs-bundle/src/middleware.ts @@ -4,6 +4,7 @@ import { NextRequest, NextResponse, type MiddlewareConfig, type NextMiddleware } import urlJoin from "url-join"; import { extractBuildId, extractNextDataPathname } from "./utils/extractNextDataPathname"; import { getPageRoute, getPageRouteMatch, getPageRoutePath } from "./utils/pageRoutes"; +import { rewritePosthog } from "./utils/rewritePosthog"; import { getXFernHostEdge } from "./utils/xFernHost"; const API_FERN_DOCS_PATTERN = /^(?!\/api\/fern-docs\/).*(\/api\/fern-docs\/)/; @@ -41,7 +42,7 @@ export const middleware: NextMiddleware = async (request) => { * Rewrite Posthog analytics ingestion */ if (nextUrl.pathname.includes("/api/fern-docs/analytics/posthog")) { - return NextResponse.rewrite(nextUrl, { request: { headers } }); + return rewritePosthog(request); } /**