Marked as helpful by the asker
The browser first sends an OPTIONS request (the preflight) before the real POST. Your function probably tries to parse a JSON body or check auth on that OPTIONS request, crashes, returns 500 → 'not HTTP ok'.
Handle it at the very top of the function, before anything else:
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
}
Deno.serve(async (req) => {
if (req.method === 'OPTIONS') {
return new Response('ok', { headers: corsHeaders })
}
// ... your code, and add corsHeaders to every response, errors too
})Curl doesn't do preflights, that's why it worked there.