23 lines
614 B
TypeScript

import { NextRequest, NextResponse } from 'next/server'
// 下载测速API
export async function POST(request: NextRequest) {
try {
const body = await request.json()
const size = body.size || 1024 * 1024 // 默认1MB
// 生成测试数据
const buffer = Buffer.alloc(size, 0)
return new NextResponse(buffer, {
headers: {
'Content-Type': 'application/octet-stream',
'Content-Length': size.toString()
}
})
} catch (error) {
console.error('下载测速失败:', error)
return NextResponse.json({ error: '下载测速失败' }, { status: 500 })
}
}