From 694cdbcf34cc4914601e44605dc1227f5fa6d2ac Mon Sep 17 00:00:00 2001 From: CharlieM <31941002+CharlieMc0@users.noreply.github.com> Date: Tue, 10 Mar 2026 09:28:50 -0700 Subject: [PATCH] fix: exclude static files from i18n middleware The Nextra locales middleware added in the i18n feature (#764) intercepts all requests, including static files in public/. This causes the OpenAPI swagger page and other static assets (images, fonts, data files) to 404 because the middleware redirects them into locale routing (/en-US/404). Add a matcher config to skip the middleware for static file paths, allowing Next.js to serve them directly from the public/ directory. Co-Authored-By: Claude Opus 4.6 --- src/middleware.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/middleware.js b/src/middleware.js index 38011cf7..ebcc094c 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -1 +1,5 @@ export { locales as middleware } from "nextra/locales"; + +export const config = { + matcher: ["/((?!data|img|fonts|favicon|api|_next/static|_next/image|.*\\.(?:svg|png|jpg|jpeg|gif|webp|ico|yaml|yml|json|woff|woff2|ttf|eot|txt|xml)$).*)"], +};