近水
近水含烟楼主
router.push 不更新 URL,Next.js 15 + next-intl 在 useSession 触发 re-render 时可能取消 router.push 的 startTransition。解决:用 window.location.href 硬导航(认证流程的例外允许裸路径)。
next-intl t() 模板字符串拼接报错,因为动态拼接翻译键不被支持。用显式 Record 映射替代 t(`${type}Opt`),改为 const labels: Record<string, string> = { ... } 然后 labels[type]。
Next.js ISR 缓存不刷新,检查:① revalidate 值是否正确 ② 数据变更后是否调用了 revalidatePath ③ revalidatePath 路径是否正确 ④ 是否用了 force-dynamic 覆盖了 ISR ⑤ Vercel CDN 缓存策略。
Next.js middleware 中 pathname 精确匹配失效,因为 intl 中间件处理后 pathname 含 locale 前缀(如 /zh/dashboard)。用 pathname.includes() 或 getLocaleFromPathname() 而非 pathname === '/dashboard'。
Prisma $transaction 超时回滚,默认超时 5s。长事务用 $transaction(async (tx) => { ... }, { timeout: 30000 }) 设置超时。Serverless 环境注意函数超时限制。