From 5f27bb99505092321feec2d8e4f713f290ae3b45 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Mon, 13 Apr 2026 23:44:01 +0200 Subject: [PATCH] chore: shift showcase asset rewrites to next.config.mjs for standalone stability --- apps/web/next.config.mjs | 19 +++++++++++++++++++ apps/web/src/middleware.ts | 7 ------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index 86f3fc9..e0a7a88 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -46,6 +46,25 @@ const nextConfig = { }, ]; }, + async rewrites() { + return { + beforeFiles: [ + // Map Patttern: Global assets moved into KLZ showcase folder + { + source: '/assets/klz-cables.com/:path*', + destination: '/showcase/klz-cables.com/assets/klz-cables.com/:path*', + }, + { + source: '/wp-content/:path*', + destination: '/showcase/klz-cables.com/wp-content/:path*', + }, + { + source: '/wp-includes/:path*', + destination: '/showcase/klz-cables.com/wp-includes/:path*', + }, + ] + }; + }, // In Standalone mode, Next.js expects the tracing root to be the monorepo root outputFileTracingRoot: path.join(dirname, '../../'), }; diff --git a/apps/web/src/middleware.ts b/apps/web/src/middleware.ts index 74a1e5b..a47d19a 100644 --- a/apps/web/src/middleware.ts +++ b/apps/web/src/middleware.ts @@ -18,13 +18,6 @@ export function middleware(request: NextRequest) { // Normalize pathname to ensure we're matching correctly const path = pathname; - // Map Pattern 1: Global assets (directly under root) - // These are often mirrored by wget/discovery engines into a domain-named subfolder - if (path.startsWith('/wp-content/') || path.startsWith('/wp-includes/') || path.startsWith('/assets/')) { - // Brute force: Re-route to the known KLZ showcase directory - return NextResponse.rewrite(new URL(`/showcase/klz-cables.com${path}`, request.url)); - } - // Map Pattern 2: Showcase-prefixed assets (used for relative links within the showcase) const showcaseMatch = path.match(/^\/(?:case-studies|work|blog)\/([^\/]+)\/(.*)/); if (showcaseMatch) {