From e683c9040447321d901a902d7abd09a9553ab5b4 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 25 Apr 2026 19:25:15 +0200 Subject: [PATCH] fix: implement inline matcher for Next.js proxy and remove unnecessary config Co-authored-by: Copilot --- proxy.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/proxy.ts b/proxy.ts index 70087666..83f02039 100644 --- a/proxy.ts +++ b/proxy.ts @@ -5,7 +5,17 @@ import { getEnabledPluginFrameOrigins } from "./lib/admin/csp-frame-origins"; const intlMiddleware = createIntlMiddleware(routing); +// Next 16's Proxy always runs on Node.js runtime and route-segment config +// (e.g. `export const config = { matcher }`) is no longer allowed in the +// proxy file. We replicate the previous matcher inline by short-circuiting +// requests for API routes, Next internals and static assets. +const PROXY_SKIP_PATTERN = /^\/(?:api|_next)(?:\/|$)|\.[^/]+$/; + export async function proxy(request: NextRequest) { + if (PROXY_SKIP_PATTERN.test(request.nextUrl.pathname)) { + return NextResponse.next(); + } + const nonce = crypto.randomUUID(); const isDev = process.env.NODE_ENV === "development"; @@ -87,9 +97,3 @@ export async function proxy(request: NextRequest) { return response; } - -// Next 16's Proxy always runs on Node.js runtime, so no `runtime` config is -// allowed (or needed) — we can read the plugin registry from disk directly. -export const config = { - matcher: ["/((?!api|_next|.*\\..*).*)"], -};