近水
近水含烟楼主
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。
Zod refine 校验不触发,检查:① refine 是否在 schema 末尾 ② 是否用了 safeParse(parse 会抛错) ③ refine 的 path 是否正确指向字段 ④ 异步 refine 用 superRefine + async。
next-intl 配置后 404,一般是 middleware 匹配规则不对。检查 middleware.ts 中 matcher 配置,确保排除了 /api、/_next、/admin 等非国际化路径。另外检查 defaultLocale 和 locales 配置是否正确。
Auth.js credentials 登录返回 null,检查:① authorize 函数是否正确返回 user 对象 ② 密码 bcrypt.compare 是否正确 ③ 用户状态是否 active ④ 是否触发了限流 ⑤ email 是否小写化匹配。
Prisma enum 在 TypeScript 中报错,确保:① 运行了 prisma generate ② import { Prisma } from '@prisma/client' 取枚举值 ③ 不要用字符串字面量而用 Prisma.EnumType 枚举 ④ schema 中 enum 定义正确。