From 314824c378ac09d40da99a95e1749cde22fbeb35 Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Tue, 10 Sep 2024 20:28:01 -0400 Subject: [PATCH] try again --- packages/ui/docs-bundle/next.config.js | 1 - packages/ui/docs-bundle/src/middleware.ts | 15 +++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/ui/docs-bundle/next.config.js b/packages/ui/docs-bundle/next.config.js index 9e64b07706..de6998ea5c 100644 --- a/packages/ui/docs-bundle/next.config.js +++ b/packages/ui/docs-bundle/next.config.js @@ -51,7 +51,6 @@ const nextConfig = { }, trailingSlash: isTruthy(process.env.TRAILING_SLASH), skipTrailingSlashRedirect: true, - skipMiddlewareUrlNormalize: true, /** * Customers who opt-in for subpath routing must use rewrite rules from their hosting provider. Because of the * multi-tenant nature of this app, we cannot set a global basepath in the next.config.js. As a result, the `_next` diff --git a/packages/ui/docs-bundle/src/middleware.ts b/packages/ui/docs-bundle/src/middleware.ts index 15d3ab40b2..991cab0680 100644 --- a/packages/ui/docs-bundle/src/middleware.ts +++ b/packages/ui/docs-bundle/src/middleware.ts @@ -51,13 +51,14 @@ export function middleware(request: NextRequest): NextResponse { } if (request.nextUrl.pathname.includes("/_next/data/")) { - const match = request.nextUrl.pathname.match(/\/_next\/data\/([^/]*)(\/.*).json/); + const match = + request.nextUrl.pathname.match(/\/_next\/data\/.*\/_next\/data\/([^/]*)(\/.*\.json).json/) ?? + request.nextUrl.pathname.match(/\/_next\/data\/([^/]*)(\/.*\.json)/); const buildId = match?.[1]; const pathname = match?.[2]; if (buildId != null && pathname != null) { - const nextDataPathname = urlJoin("/static/", xFernHost, pathname); + const nextDataPathname = urlJoin("/static/", xFernHost, pathname).replace(".json", ""); const destination = new URL(nextDataPathname, request.url); - // destination.search = request.nextUrl.search; destination.searchParams.set("__nextDataReq", "1"); return NextResponse.rewrite(destination); } @@ -77,12 +78,6 @@ export const config = { * - _next/image (image optimization files) * - favicon.ico (favicon file) */ - { - source: "/((?!api|_next/static|_next/image|favicon.ico).*)", - missing: [ - { type: "header", key: "next-router-prefetch" }, - { type: "header", key: "purpose", value: "prefetch" }, - ], - }, + "/((?!api|_next/static|_next/image|favicon.ico).*)", ], };