nomadro/app/book/api/feedback/route.ts
eric 9928c5185b Mount nav/book/community as native App Router routes in one Next process.
Replace reverse-proxy/iframe approach with @ebook/@community/@navmini imports under /nav /book /community so localhost:3000 serves all three products directly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 03:49:16 -05:00

36 lines
1.0 KiB
TypeScript

import { NextResponse } from 'next/server';
import { getBook } from '@ebook/lib/book.server';
import { getSiteConfig } from '@ebook/lib/site-config.server';
export async function POST(req: Request) {
try {
const body = (await req.json()) as { email?: string; message?: string };
const message = body.message?.trim();
if (!message || message.length < 4) {
return NextResponse.json({ ok: false, error: 'message required' }, { status: 400 });
}
const book = getBook();
const site = getSiteConfig();
const payload = {
book: book.title,
email: body.email?.trim() || '',
message,
at: new Date().toISOString(),
};
const webhook = process.env.FEEDBACK_WEBHOOK_URL?.trim();
if (webhook) {
await fetch(webhook, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
}
return NextResponse.json({ ok: true });
} catch {
return NextResponse.json({ ok: false }, { status: 500 });
}
}