数据
数据淘金客楼主
Server Action 提交后不跳转,可能是用了 router.push 而非 window.location.href。Next.js 15 + next-intl 的 router.push 在 startTransition 内会被 toast 的状态更新中断。解决:用 window.location.href 硬导航。
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。
middleware 重定向循环,一般是认证逻辑和业务重定向冲突。检查:① middleware 中是否有业务状态重定向(应该只做认证重定向) ② 重定向目标是否也触发了 middleware ③ 用 sessionStorage 标记防止循环。
next-intl 配置后 404,一般是 middleware 匹配规则不对。检查 middleware.ts 中 matcher 配置,确保排除了 /api、/_next、/admin 等非国际化路径。另外检查 defaultLocale 和 locales 配置是否正确。