Files
gitlab-instance-0a899031_no…/docs/DEPLOYMENT.md
2026-03-12 04:11:29 -05:00

33 lines
897 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 部署说明
## 解决 "Failed to find Server Action" 错误
在 PM2 自托管 Next.js 时,若出现以下错误:
```
Error: Failed to find Server Action. This request might be from an older or newer deployment.
```
**原因**Next.js 为 Server Actions 使用加密密钥,每次构建会重新生成。部署后客户端可能仍缓存旧版本 JS导致请求的 action ID 与服务器不匹配。
**解决方案**:项目已内置 `config/server-actions.key`,构建时 `next.config.ts` 会自动加载,无需手动配置。直接执行 `pnpm build` 即可。
部署后若仍有问题可让用户执行硬刷新Ctrl+Shift+R或清除浏览器缓存。
---
## PM2 部署流程
```bash
# 1. 安装依赖
pnpm install
# 2. 构建(自动加载 config/server-actions.key
pnpm build
# 3. 启动
pnpm start
# 或使用 PM2
pm2 start npm --name vip -- start
```