import { NextResponse } from "next/server"; import { getAllPosts } from "@/lib/blog"; export const dynamic = "force-dynamic"; export async function GET(request: Request) { console.log("[API] 🌐 GET /api/blog - Request received"); try { const { searchParams } = new URL(request.url); const category = searchParams.get("category") as "case-study" | "blog" | null; console.log("[API] 📋 Parameters:", { category }); const posts = await getAllPosts(category || undefined); console.log("[API] ✅ Response ready:", { count: posts.length }); return NextResponse.json({ success: true, posts, count: posts.length, }); } catch (error) { console.error("[API] ❌ Error:", error); return NextResponse.json({ success: false, error: "Failed to fetch posts" }, { status: 500 }); } }