Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(docs): bypass locale routing for favicon (#9946)
Bohan Jiang7c15cc4e7485
diff --git a/apps/docs/proxy.test.ts b/apps/docs/proxy.test.tsnew file mode 100644index 0000000000..7521f4064e--- /dev/null+++ b/apps/docs/proxy.test.ts@@ -0,0 +1,23 @@+// @vitest-environment node++import "next/dist/server/node-environment-baseline";+import { unstable_doesMiddlewareMatch } from "next/experimental/testing/server";+import { describe, expect, it } from "vitest";+import nextConfig from "./next.config.mjs";+import { config } from "./proxy";++describe("docs locale proxy matcher", () => {+ it.each(["/docs/icon.svg", "/docs/icon.svg?icon.1234.svg"])(+ "serves the favicon without a locale rewrite at %s",+ (url) => {+ expect(unstable_doesMiddlewareMatch({ config, nextConfig, url })).toBe(false);+ },+ );++ it.each(["/docs", "/docs/agents", "/docs/zh", "/docs/fr/agents"])(+ "keeps locale routing enabled for %s",+ (url) => {+ expect(unstable_doesMiddlewareMatch({ config, nextConfig, url })).toBe(true);+ },+ );+});diff --git a/apps/docs/proxy.ts b/apps/docs/proxy.tsindex 501c384f0b..235d3db774 100644--- a/apps/docs/proxy.ts+++ b/apps/docs/proxy.ts@@ -45,12 +45,11 @@ export function proxy(request: NextRequest) {export const config = {// Run on every path except static/api and root metadata routes. Includes- // the bare `/` root so `/docs/` lands on the English home. `sitemap.xml`- // and `robots.txt` MUST be excluded — they're not under `[lang]/`, so- // routing them through the locale rewrite would 404 the sitemap that- // robots.txt advertises to crawlers.+ // the bare `/` root so `/docs/` lands on the English home. Metadata routes+ // such as `icon.svg` are not under `[lang]/` and must bypass locale routing+ // so browsers and crawlers can fetch the original resources.matcher: [- "/((?!api|_next/static|_next/image|images|favicon.ico|sitemap.xml|robots.txt).*)",+ "/((?!api|_next/static|_next/image|images|favicon.ico|icon\\.svg$|sitemap.xml|robots.txt).*)","/",],};