From 09a2f4ca04dc5f989985d8886cabf070641eff45 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 17:41:26 +0000 Subject: [PATCH] =?UTF-8?q?fix(proxy):=20matcher=20=E6=8E=92=E9=99=A4=20oa?= =?UTF-8?q?uth/auth/analytics=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=20404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #330 i18n PR 让 next-intl middleware 接管全站 locale routing,但 matcher 只排除了 api/trpc/_next/_vercel/静态资源,没排除 next.config.mjs 的 rewrites 直通后端的路径。现象: - 用户访问 /oauth/render/github - next-intl middleware 308 redirect 到 /en/oauth/render/github (按 cookie / Accept-Language 推断 locale) - next.config rewrite source 是 /oauth/:path* 不带 locale,不匹配 - 落到 app/[locale]/oauth/... 但这个 page 不存在 → 404 - 登录炸 3 条 rewrite-to-backend 路径都要排: - /auth/:path* NextAuth-like (/auth/me, /auth/logout) - /oauth/:path* OAuth 跳转入口(登录关键) - /analytics/:path* 埋点 加进 matcher 排除组: /((?!api|trpc|auth|oauth|analytics|_next|_vercel|.*\..*).*) --- proxy.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/proxy.ts b/proxy.ts index bbb5243..342237f 100644 --- a/proxy.ts +++ b/proxy.ts @@ -83,7 +83,11 @@ export function proxy(req: NextRequest) { export const config = { // Match all pathnames except for // - api / trpc:API 路由不进 i18n(无 UI,纯 fetch) + // - auth / oauth / analytics:next.config rewrites 直通后端的路径 + // (登录 / OAuth / 埋点)。被 next-intl 加了 locale 前缀后, + // rewrite source(/oauth/:path*)不匹配带 locale 的版本(/en/oauth/...), + // 落到 [locale]/oauth/... 404。所以必须排除掉,让请求直接走 rewrite。 // - _next / _vercel:Next.js 内部 // - .*\..*:任何带 . 的路径(静态资源 / sitemap.xml / robots.txt 等) - matcher: "/((?!api|trpc|_next|_vercel|.*\\..*).*)", + matcher: "/((?!api|trpc|auth|oauth|analytics|_next|_vercel|.*\\..*).*)", };