import { NextResponse } from 'next/server';
import { withAuth } from '../../../../lib/with-auth';

const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080';

export const POST = withAuth(async (req, session) => {
  const body = await req.json();
  const res = await fetch(`${API_BASE}/api/products/pending`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${session.accessToken}` },
    body: JSON.stringify(body),
  });
  const data = await res.json();
  return NextResponse.json(data, { status: res.status });
});
