蜕皮
蜕皮的蛇楼主
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。
Auth.js 5 signIn redirect:false 返回 { error, ok, status, url }。判断成功:!result.error && result.ok。注意 result.url 可能含 ?error= 参数,用 redirectTo 显式指定避免误判。
revalidateTag vs revalidatePath:revalidateTag 清除特定 tag 的缓存(fetch 时用 next.tags 标记),revalidatePath 清除特定路径的缓存。数据变更后 revalidatePath 更直接,精细控制用 revalidateTag。
Shadcn UI 组件在 Server Component 报错,因为部分组件用了 Radix UI(Client Component)。确保使用 Shadcn 组件的页面或父组件加了 'use client',或者把组件包裹在 Client Component wrapper 中。
Next.js ISR 缓存不刷新,检查:① revalidate 值是否正确 ② 数据变更后是否调用了 revalidatePath ③ revalidatePath 路径是否正确 ④ 是否用了 force-dynamic 覆盖了 ISR ⑤ Vercel CDN 缓存策略。