import { NextRequest, NextResponse } from "next/server"; import { postSalonApi } from "@/app/lib/salonApi"; export async function POST(request: NextRequest) { try { const body = await request.json().catch(() => ({})); const email = String(body?.email || "").trim(); const password = String(body?.password || "").trim(); if (!email) { return NextResponse.json({ ok: false, error: "请输入邮箱" }, { status: 400 }); } const { status, data } = await postSalonApi(request, "/api/salon/ensure-user", { email, password: password || undefined, }); if (status >= 500) { const payload = typeof data === "object" && data !== null ? (data as Record) : {}; return NextResponse.json( { ok: false, error: (payload.error as string) || "操作失败" }, { status: 503 } ); } return NextResponse.json(data, { status }); } catch (error) { console.error("salon ensure-user error:", error); return NextResponse.json({ ok: false, error: "操作失败" }, { status: 500 }); } }