export default defineEventHandler(async (event) => { const body = await readBody(event) // Proxy to real backend API try { const config = useRuntimeConfig() const res = await $fetch<{code:number|string; message:string; data?:any}>(`${config.public.apiPrefix}/leads`, { method: 'POST', body: { ...body, source: 'official_website', submittedAt: new Date().toISOString() } }) return res } catch(e: any) { console.error('[lead proxy] backend unreachable, falling back to mock:', e.message) return { code: 200, message: 'success', data: { id: Date.now() }, requestId: 'mock-' + Date.now(), timestamp: Date.now() } } })