GET 和 POST 同时写入 api/nav/route.ts 文件中。本地开发环境正常。但是通过 vercel 部署后,GET 请求返回数据缺失了一部分。如果把 POST 函数注释掉,GET 请求返回正常结果?
export async function GET(request: Request) {
const test = []
for (const name of await fs.readdir(
path.resolve(process.cwd(), 'app/blog/data_structure/tree')
)) {
test.push(name)
}
const result = {
code: 200,
test: test,
}
return NextResponse.json(result)
}
export async function POST(request: Request) {
return NextResponse.json({ data: true })
}
{
"code": 200,
"test": [
"readme.mdx"
]
}
{
"code": 200,
"test": [
"page.tsx",
"readme.mdx"
]
}