fix: 完整修复 Vercel 部署配置

关键修复:
- 设置 Node.js 版本为 18.x(Vercel 要求)
- 排除 api/ 目录不被 TypeScript 编译
- 简化 vercel.json,让 Vercel 自动处理构建
- api/index.ts 作为独立 serverless 函数运行

技术说明:
- Vercel 的 api/ 目录是特殊目录,自动识别为 serverless 函数
- api/index.ts 会被映射到 /api 路由
- src/ 目录正常编译到 dist/,供 api/index.ts 导入使用

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
golc 2026-03-04 09:54:02 +00:00
parent 7f35617f64
commit 7185009c28
3 changed files with 4 additions and 9 deletions

View File

@ -6,7 +6,7 @@
"private": true,
"license": "UNLICENSED",
"engines": {
"node": "20.x"
"node": "18.x"
},
"scripts": {
"build": "npx nest build",

View File

@ -17,5 +17,6 @@
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
}
},
"exclude": ["node_modules", "dist", "api"]
}

View File

@ -1,9 +1,3 @@
{
"version": 2,
"buildCommand": "pnpm run build",
"functions": {
"api/*.ts": {
"runtime": "@vercel/node@2.15.10"
}
}
"version": 2
}