aiagentdlafirm/app/api/blog/route.ts
Adrian Miesikowski 39565dc522
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 28s
Switch from ISR to full SSR + add comprehensive logging
2026-02-10 20:57:00 +01:00

26 lines
839 B
TypeScript

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 });
}
}