// CORS headers for Edge Functions export const corsHeaders = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type', 'Access-Control-Allow-Methods': 'GET, POST, PUT, PATCH, DELETE, OPTIONS', }; // Handle CORS preflight export function handleCors(req: Request): Response | null { if (req.method === 'OPTIONS') { return new Response(null, { status: 204, headers: corsHeaders, }); } return null; } // Create error response with CORS export function createErrorResponse(status: number, message: string): Response { return new Response( JSON.stringify({ error: message }), { status, headers: { ...corsHeaders, 'Content-Type': 'application/json', }, } ); } // Create success response with CORS export function createSuccessResponse(data: any, status = 200): Response { return new Response( JSON.stringify(data), { status, headers: { ...corsHeaders, 'Content-Type': 'application/json', }, } ); }