diff --git a/supabase/functions/_shared/cors.ts b/supabase/functions/_shared/cors.ts deleted file mode 100644 index 3473e0b17..000000000 --- a/supabase/functions/_shared/cors.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const corsHeaders = { - "Access-Control-Allow-Origin": "*", - "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type", - "Access-Control-Allow-Methods": "POST, OPTIONS", -}; diff --git a/supabase/functions/ai-stream/index.ts b/supabase/functions/ai-stream/index.ts index 3e875e808..3c5aa589c 100644 --- a/supabase/functions/ai-stream/index.ts +++ b/supabase/functions/ai-stream/index.ts @@ -81,10 +81,7 @@ function getProviderForModel(model: string): "openai" | "google" | "anthropic" | } function jsonResponse(body: Record, status: number, corsHeaders: Record) { - return new Response(JSON.stringify(body), { - status, - headers: { ...corsHeaders, "Content-Type": "application/json" }, - }); + return Response.json(body, { status, headers: corsHeaders }); } function sse(event: string, payload: Record) { diff --git a/supabase/functions/ai/index.ts b/supabase/functions/ai/index.ts index 1cfe8b675..227c27a2b 100644 --- a/supabase/functions/ai/index.ts +++ b/supabase/functions/ai/index.ts @@ -27,13 +27,6 @@ function getCorsHeaders(origin: string | null) { type Feature = "generate" | "attack" | "brainstorm" | "factoids" | "ask" | "sparring" | "crossfire"; -type Source = { - title: string; - content: string; - origin?: string; - type: string; -}; - // Generate unique request ID for tracing function generateRequestId(): string { return `edge_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`; diff --git a/supabase/functions/announcements/index.ts b/supabase/functions/announcements/index.ts index b61382a45..af0154a95 100644 --- a/supabase/functions/announcements/index.ts +++ b/supabase/functions/announcements/index.ts @@ -23,10 +23,7 @@ function getCorsHeaders(origin: string | null) { } function json(data: unknown, status: number, corsHeaders: Record) { - return new Response(JSON.stringify(data), { - status, - headers: { ...corsHeaders, "Content-Type": "application/json" }, - }); + return Response.json(data, { status, headers: corsHeaders }); } Deno.serve(async (req) => { diff --git a/supabase/functions/import-source/index.ts b/supabase/functions/import-source/index.ts index 9e7203b9f..e6f5977b0 100644 --- a/supabase/functions/import-source/index.ts +++ b/supabase/functions/import-source/index.ts @@ -33,10 +33,7 @@ const supabaseServiceKey = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!; const supabase = createClient(supabaseUrl, supabaseServiceKey); function jsonResponse(body: unknown, status: number, headers: Record) { - return new Response(JSON.stringify(body), { - status, - headers: { ...headers, "Content-Type": "application/json" }, - }); + return Response.json(body, { status, headers }); } async function isUserBanned(userId: string): Promise {