supabase icon indicating copy to clipboard operation
supabase copied to clipboard

[email protected]'s Project

Open Jamersoncw opened this issue 7 months ago • 1 comments

Describe the bug My Edge Function is consistently failing with a 500 Internal Server Error on every OPTIONS preflight request from the browser. This results in a CORS error on the client-side.

The issue persists even after deploying a minimal test function that only returns a 200 OK response with CORS headers. I have also tried deleting the function completely and redeploying it, but the 500 error remains. This suggests a platform or environmental issue.

To Reproduce

  1. Create a new Edge Function.
  2. Deploy the minimal code provided below.
  3. Try to call it from any browser-based client (e.g., using fetch in the browser console).
  4. The OPTIONS preflight request fails with a 500 status code.

Expected behavior The minimal test function should return a 200 status code for the OPTIONS request, not a 500 error.

Project information:

  • Project ref: qlbwvpvtamlzlzvjovux
  • Region: sa-east-1

Minimal code that reproduces the error:

import { serve } from "[https://deno.land/[email protected]/http/server.ts](https://deno.land/[email protected]/http/server.ts)"

const corsHeaders = {
  'Access-Control-Allow-Origin': '*',
  'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
  'Access-Control-Allow-Methods': 'POST, OPTIONS',
};

serve(async (req) => {
  // Responds immediately to the CORS preflight request
  if (req.method === 'OPTIONS') {
    return new Response('ok', { status: 200, headers: corsHeaders });
  }

  return new Response('ok', { status: 200, headers: corsHeaders });

Jamersoncw avatar Jun 12 '25 01:06 Jamersoncw

Please share the code you are using to call the edge function.

silentworks avatar Jun 12 '25 11:06 silentworks

Hi all, We’re going to close this one due to inactivity. Please feel free to reopen if you’re still having issues here or open a new issue.

Hallidayo avatar Jun 23 '25 18:06 Hallidayo