#新人报道#
Vercel生产环境post处理函数导致get处理函数响应错误数据?
github.com
重现
1、不要注释掉app/api/nav/route.ts文件的POST处理函数
2、通过vercel部署,默认选择nextjs框架
- 异常响应: vercel生产环境上的post处理函数没有进行注释,page.tsx 文件名丢失,
{
"code": 200,
"test": [
"readme.mdx"
]
}
- 正常响应: vercel生产环境上的post处理函数注释掉
{
"code": 200,
"test": [
"page.tsx",
"readme.mdx"
]
}
源码中确实存在page.tsx这个文件
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 })
}
Vercel生产环境post处理函数导致get处理函数响应错误数据?
重现
1、不要注释掉app/api/nav/route.ts文件的POST处理函数
2、通过vercel部署,默认选择nextjs框架
- 异常响应: vercel生产环境上的post处理函数没有进行注释,page.tsx 文件名丢失,
{
"code": 200,
"test": [
"readme.mdx"
]
}
- 正常响应: vercel生产环境上的post处理函数注释掉
{
"code": 200,
"test": [
"page.tsx",
"readme.mdx"
]
}
源码中确实存在page.tsx这个文件
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 })
}
展开
评论
3