Files
users/app/api/auth/send-code/route.ts

32 lines
891 B
TypeScript
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.

import { NextRequest, NextResponse } from "next/server"
/**
* 本地验证码发送 API (mock)
* 开发环境下直接返回成功验证码可为任意4位以上
*/
export async function POST(request: NextRequest) {
try {
const formData = await request.formData()
const phone = (formData.get("phone") || "").toString().trim()
if (!phone) {
return NextResponse.json(
{ code: 40001, message: "请输入手机号" },
{ status: 200 }
)
}
// Mock: 模拟发送成功,开发时可用 123456 等作为验证码
return NextResponse.json({
code: 10000,
message: "验证码已发送开发模式可使用任意4位以上数字",
})
} catch (error) {
console.error("[auth/send-code]", error)
return NextResponse.json(
{ code: 50000, message: "服务器错误" },
{ status: 500 }
)
}
}