快乐
快乐的水豚楼主
Auth.js 5 beta 的 session 丢失问题,常见原因:① AUTH_SECRET 未配置或变了 ② cookie 被中间件清除 ③ JWT 过期。排查:检查 AUTH_SECRET 是否一致,middleware 中是否有不必要的 Set-Cookie,callbacks.jwt 是否正确返回 token。
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。
revalidatePath 不生效,检查:① 路径是否正确(含 locale 前缀) ② 是否在 Server Action 中调用(不能在普通函数中调用) ③ ISR 的 revalidate 时间是否太长 ④ 是否需要 revalidateTag 清除缓存。
Shadcn UI 组件在 Server Component 报错,因为部分组件用了 Radix UI(Client Component)。确保使用 Shadcn 组件的页面或父组件加了 'use client',或者把组件包裹在 Client Component wrapper 中。