Prisma 索引没生效导致查询很慢
Next.js middleware 中 pathname 精确匹配失效,因为 intl 中间件处理后 pathname 含 locale 前缀(如 /zh/dashboard)。用 pathname.includes() 或 getLocaleFromPathname() 而非 pathname...
Next.js middleware 中 pathname 精确匹配失效,因为 intl 中间件处理后 pathname 含 locale 前缀(如 /zh/dashboard)。用 pathname.includes() 或 getLocaleFromPathname() 而非 pathname...
Next.js middleware 中 pathname 精确匹配失效,因为 intl 中间件处理后 pathname 含 locale 前缀(如 /zh/dashboard)。用 pathname.includes() 或 getLocaleFromPathname() 而非 pathname...
Prisma 连接池超时一般是 connection_limit 设置不当。Serverless 环境(Vercel)建议 connection_limit=1,因为每个函数实例独立连接。如果用 PgBouncer 或 Supabase connection pooler,URL 加 ?pgboun...
Google OAuth 回调报 OAuthCallback 错误,检查:① GOOGLE_CLIENT_ID/SECRET 是否正确 ② NEXTAUTH_URL 是否与 Google Console 中的回调 URL 一致 ③ redirect URI 是否匹配 ④ 时钟同步问题。 Next....
Shadcn UI 组件在 Server Component 报错,因为部分组件用了 Radix UI(Client Component)。确保使用 Shadcn 组件的页面或父组件加了 'use client',或者把组件包裹在 Client Component wrapper 中。 Verce...
React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子...
React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子...
Tailwind v4 升级后样式失效,大版本升级有 breaking changes。检查:① tailwind.config.ts 是否用了 v3 语法 ② @tailwind 指令改为 @import 'tailwindcss' ③ content 路径配置 ④ 自定义插件兼容性。建议看官方迁...
router.push 不更新 URL,Next.js 15 + next-intl 在 useSession 触发 re-render 时可能取消 router.push 的 startTransition。解决:用 window.location.href 硬导航(认证流程的例外允许裸路径)。...
React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子...
Prisma migrate 报 database does not exist,需要先创建数据库。用 npx prisma db push 或手动 createdb。如果是 Vercel Postgres 或 Supabase,确保 DATABASE_URL 指向正确的数据库实例。 Prisma...
Prisma enum 在 TypeScript 中报错,确保:① 运行了 prisma generate ② import { Prisma } from '@prisma/client' 取枚举值 ③ 不要用字符串字面量而用 Prisma.EnumType 枚举 ④ schema 中 enum...
revalidateTag vs revalidatePath:revalidateTag 清除特定 tag 的缓存(fetch 时用 next.tags 标记),revalidatePath 清除特定路径的缓存。数据变更后 revalidatePath 更直接,精细控制用 revalidateTa...
Next.js 路由组 layout 中调用 auth() 报错,因为 layout 是所有子页面的公共外壳,async layout 会拖慢导航。解决:layout 保持同步,用客户端组件 + useSession() 读取 session 缓存。 Vercel 构建时 TypeScript 检...
toast 和 router.push 冲突,因为 toast 的状态更新会中断 router.push 的 startTransition。解决:用 window.location.href 硬导航,或先 toast 再 setTimeout(() => router.push, 0)。 Pri...
revalidateTag vs revalidatePath:revalidateTag 清除特定 tag 的缓存(fetch 时用 next.tags 标记),revalidatePath 清除特定路径的缓存。数据变更后 revalidatePath 更直接,精细控制用 revalidateTa...
Shadcn UI 组件在 Server Component 报错,因为部分组件用了 Radix UI(Client Component)。确保使用 Shadcn 组件的页面或父组件加了 'use client',或者把组件包裹在 Client Component wrapper 中。 Next....
next-intl t() 模板字符串拼接报错,因为动态拼接翻译键不被支持。用显式 Record 映射替代 t(`${type}Opt`),改为 const labels: Record<string, string> = { ... } 然后 labels[type]。 Vercel 部署后 C...
Prisma Json 字段查询,用 prismaToJson 过滤或 $queryRaw 用 PostgreSQL 的 ->> 操作符。Prisma 6 支持直接在 where 中用 path 过滤 Json 字段。 Prisma 软删除查询过滤重复,用 middleware 自动过滤 dele...
Next.js 动态 import 水合报错,可能是动态组件的 SSR 输出与客户端不一致。加 ssr: false 避免服务端渲染,或确保组件在 SSR 和 CSR 中输出一致。 next-intl t() 模板字符串拼接报错,因为动态拼接翻译键不被支持。用显式 Record 映射替代 t(`$...