diff --git a/api/blog/index.ts b/api/blog/index.ts index 6761da0b..c0a0880e 100644 --- a/api/blog/index.ts +++ b/api/blog/index.ts @@ -1,4 +1,5 @@ import { createClient } from "@supabase/supabase-js"; +import type { VercelRequest, VercelResponse } from "@vercel/node"; const supabaseUrl = process.env.SUPABASE_URL || ""; const supabaseServiceRole = process.env.SUPABASE_SERVICE_ROLE || ""; @@ -115,13 +116,15 @@ async function fetchFromSupabase(limit: number = 50): Promise { } } -export default async function handler(req: any, res: any) { +export default async function handler(req: VercelRequest, res: VercelResponse) { + res.setHeader("Content-Type", "application/json"); + if (req.method !== "GET") { return res.status(405).json({ error: "Method not allowed" }); } try { - const limit = Math.min(parseInt(req.query.limit as string) || 50, 100); + const limit = Math.min(parseInt((req.query.limit as string) || "50"), 100); // Try Ghost first, then Supabase let posts = await fetchFromGhost(limit);