离线
离线爱好者楼主
Next.js middleware 中 pathname 精确匹配失效,因为 intl 中间件处理后 pathname 含 locale 前缀(如 /zh/dashboard)。用 pathname.includes() 或 getLocaleFromPathname() 而非 pathname === '/dashboard'。 middleware 重定向循环,一般是认证逻辑和业务重定向冲突。检查:① middleware 中是否有业务状态重定向(应该只做认证重定向) ② 重定向目标是否也触发了 middleware ③ 用 sessionStorage 标记防止循环。 Tailwind v4 升级后样式失效,大版本升级有 breaking changes。检查:① tailwind.config.ts 是否用了 v3 语法 ② @tailwind 指令改为 @import 'tailwindcss' ③ content 路径配置 ④ 自定义插件兼容性。建议看官方迁移指南。 toast 和 router.push 冲突,因为 toast 的状态更新会中断 router.push 的 startTransition。解决:用 window.location.href 硬导航,或先 toast 再 setTimeout(() => router.push, 0)。 React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子组件 Client 做交互。