需求
需求翻译机楼主
部署流程:GitHub push → Vercel 自动构建 → Preview 环境 → 合并到 main → Production 环境。环境变量在 Vercel Dashboard 配置,区分 Production/Preview/Development。数据库迁移用 GitHub Actions 在部署前自动执行 prisma migrate deploy。
踩坑最深的莫过于 Server Component 中 cookies().set() 和 redirect() 不兼容的问题。一开始在 page.tsx 里设置 cookie 后 redirect,cookie 死活不生效。后来改成 Server Action 就好了。另外 next/dynamic + ssr:false 不能在 Server Component 中用,得包一层 'use client' 组件。
技术架构上,Server Component 做数据获取和 SEO 输出,Client Component 只负责交互。用 Server Action 处理表单提交,Zod 校验输入,错误消息走 next-intl i18n。认证用 Auth.js 5 JWT 模式,中间件做认证重定向和 API 限流。
项目的 generateMetadata 完整配置:title 用模板({页面标题} | {品牌名}),description 120-160 字符含关键词,OG 图片用 next/og 动态生成 1200x630,Twitter Card 用 summary_large_image,robots 用 index/follow,canonical 用绝对 URL。