Skip to content

Commit

Permalink
try again
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Sep 11, 2024
1 parent 565c820 commit 314824c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
1 change: 0 additions & 1 deletion packages/ui/docs-bundle/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
15 changes: 5 additions & 10 deletions packages/ui/docs-bundle/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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).*)",
],
};

0 comments on commit 314824c

Please sign in to comment.