© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago
Charles de Dreuille

I'm having CORS issues when upgrading functions to use Supabase v2.0.0

Since Supabase JS is now available in v2 I'm trying to modify my edge function to use this new version but I'm having CORS issues when I remove
JSON.stringify()
JSON.stringify()
from the body when invoking the function.

Invoke before
await supabaseClient.functions.invoke("media-upload", {
  body: JSON.stringify({
    path: fileName,
  }),
});
await supabaseClient.functions.invoke("media-upload", {
  body: JSON.stringify({
    path: fileName,
  }),
});

Invoke after
await supabaseClient.functions.invoke("media-upload", {
  body: {
    path: fileName,
  },
});
await supabaseClient.functions.invoke("media-upload", {
  body: {
    path: fileName,
  },
});


In my function:
const corsHeaders = {
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Headers": "authorization, x-client-info, apikey",
};

serve(async (req) => {
  if (req.method === "OPTIONS") {
    return new Response("ok", { headers: corsHeaders });
  }

  try {
    ...
  } catch (error) {
    ...
  }
});
const corsHeaders = {
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Headers": "authorization, x-client-info, apikey",
};

serve(async (req) => {
  if (req.method === "OPTIONS") {
    return new Response("ok", { headers: corsHeaders });
  }

  try {
    ...
  } catch (error) {
    ...
  }
});


Any idea why if I remove
JSON.stringify()
JSON.stringify()
I get a CORS error? It seems that now we have to remove it with v2.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Authentication persistence issues when upgrading Supabase Flutter from v1 to v2
SupabaseSSupabase / help-and-questions
2mo ago
CORS issues when invoking functions via browser
SupabaseSSupabase / help-and-questions
4y ago
Upgrading supabase into v2 subscribe
SupabaseSSupabase / help-and-questions
4y ago
Upgrading to Supabase Pro Plan
SupabaseSSupabase / help-and-questions
5mo ago