import { $fetch } from 'ofetch' import { createError, defineEventHandler, readBody } from 'h3' import { useRuntimeConfig } from '#imports' import { getTenantFromContext } from '../../../utils/tenant' /** * 密码找回-提交申请(**匿名**,企业未登录时提交) * POST /api/tender/password/apply { enterpriseName, creditCode, newPassword, confirmPassword, handbookUrl } * 代理到 mp-api /api/hjc/auth/password/apply。 * * 注意:该接口对「企业不存在 / 双要素不匹配 / 已有待审核申请」一律返回**同一句话且 data 为 null**, * 以免暴露某个企业是否在本平台注册过。前端因此不能靠 message 区分结果,只提示「已提交」并引导去查进度。 */ export default defineEventHandler(async (event) => { const config = useRuntimeConfig() const ctx = getTenantFromContext(event, config) const body = await readBody(event) try { return await $fetch('/hjc/auth/password/apply', { baseURL: config.public.modulesApiBase, method: 'POST', headers: { TenantId: ctx.tenantId }, query: { TenantId: ctx.tenantId }, body }) } catch (error: any) { throw createError({ statusCode: error?.statusCode || error?.response?.status || 502, statusMessage: error?.data?.message || error?.statusMessage || '提交失败' }) } })