Tailwind v4 容器查询不生效
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。 Ne...
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。 Ne...
Vercel 构建时 TypeScript 检查失败,可以在 next.config.ts 中设置 typescript.ignoreBuildErrors = true 临时跳过,但不推荐。正确做法:本地运行 npm run typecheck 修复所有类型错误后再部署。 generateSta...
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。 Pr...
next-intl t() 模板字符串拼接报错,因为动态拼接翻译键不被支持。用显式 Record 映射替代 t(`${type}Opt`),改为 const labels: Record<string, string> = { ... } 然后 labels[type]。 Next.js 路由组...
Next.js middleware 中 pathname 精确匹配失效,因为 intl 中间件处理后 pathname 含 locale 前缀(如 /zh/dashboard)。用 pathname.includes() 或 getLocaleFromPathname() 而非 pathname...
遇到 hydration mismatch 报错,一般是服务端和客户端渲染的 HTML 不一致。常见原因:① 在组件中用了 Date.now() 或 Math.random() ② 用了 window/document 等浏览器 API ③ 服务端和客户端时区不同。解决:把动态值放到 useEffe...
revalidateTag vs revalidatePath:revalidateTag 清除特定 tag 的缓存(fetch 时用 next.tags 标记),revalidatePath 清除特定路径的缓存。数据变更后 revalidatePath 更直接,精细控制用 revalidateTa...
Prisma Json 字段查询,用 prismaToJson 过滤或 $queryRaw 用 PostgreSQL 的 ->> 操作符。Prisma 6 支持直接在 where 中用 path 过滤 Json 字段。 next/image 图片模糊或变形,检查:① 是否设置了 width/hei...
Next.js 路由组 layout 中调用 auth() 报错,因为 layout 是所有子页面的公共外壳,async layout 会拖慢导航。解决:layout 保持同步,用客户端组件 + useSession() 读取 session 缓存。 Vercel 环境变量不生效,检查三点:① 环...
Prisma $queryRaw 中 camelCase 列名必须加双引号:SELECT "newUserQuota" FROM users。不加双引号 PostgreSQL 会当作不区分大小写的标识符,找不到 camelCase 列。TS 类型声明也要与 SQL 别名一致。 Auth.js JW...
Auth.js credentials 登录返回 null,检查:① authorize 函数是否正确返回 user 对象 ② 密码 bcrypt.compare 是否正确 ③ 用户状态是否 active ④ 是否触发了限流 ⑤ email 是否小写化匹配。 Next.js 15 中 cookie...
Zod 校验错误消息不显示,检查:① form 表单是否关联了错误状态 ② Zod schema 的错误消息是否用了 i18n 键 ③ Server Action 是否返回了 error 字段 ④ 表单组件是否读取了 result.error 并显示。 Auth.js credentials 登录...
next-intl 配置后 404,一般是 middleware 匹配规则不对。检查 middleware.ts 中 matcher 配置,确保排除了 /api、/_next、/admin 等非国际化路径。另外检查 defaultLocale 和 locales 配置是否正确。 useSessio...
Zod refine 校验不触发,检查:① refine 是否在 schema 末尾 ② 是否用了 safeParse(parse 会抛错) ③ refine 的 path 是否正确指向字段 ④ 异步 refine 用 superRefine + async。 Next.js 15 中 next/...
Prisma 多对多关系创建,用 connect 或 create 连接:prisma.user.create({ data: { roles: { connect: [{ id: roleId }] } } })。隐式多对多表 Prisma 自动管理,显式多对多需要自己管理中间表。 revali...
Prisma @@map 是表名映射(模型 → 数据库表名),字段 @map 是列名映射。混淆会导致查询的表/列名不匹配。规则:模型 PascalCase + @@map('snake_case'),字段 camelCase(DB 用 snake_case 时加 @map)。 Vercel Edg...
Auth.js 5 signIn redirect:false 返回 { error, ok, status, url }。判断成功:!result.error && result.ok。注意 result.url 可能含 ?error= 参数,用 redirectTo 显式指定避免误判。 Pri...
Auth.js JWT token 中字段不更新,因为 JWT 是有状态的快照。修改用户字段后需要用 useSession().update() 刷新客户端 session,同时 JWT callback 中处理 trigger === 'update' 从 DB 读取最新值更新 token。 G...
Next.js middleware 中 pathname 精确匹配失效,因为 intl 中间件处理后 pathname 含 locale 前缀(如 /zh/dashboard)。用 pathname.includes() 或 getLocaleFromPathname() 而非 pathname...
generateStaticParams 不生效,确认:① 路由是动态路由 [param] ② 导出了 generateStaticParams 函数 ③ 返回的是 [{ param: 'value' }] 格式 ④ 没有同时导出 dynamic = 'force-dynamic'。 Vercel...