Browse Source

fix: use service role client for oauth_states insert #17

Claude 5 months ago
parent
commit
585b6f7
1 changed files with 4 additions and 1 deletions
  1. 4 1
      supabase/functions/oauth-woocommerce/index.ts

+ 4 - 1
supabase/functions/oauth-woocommerce/index.ts

@@ -176,8 +176,11 @@ serve(async (req) => {
       // Generate state for CSRF protection
       const state = crypto.randomUUID()
 
+      // Create Supabase admin client for storing state (requires service role)
+      const supabaseAdmin = createClient(supabaseUrl, supabaseServiceKey)
+
       // Store state in database
-      const { error: stateError } = await supabase
+      const { error: stateError } = await supabaseAdmin
         .from('oauth_states')
         .insert({
           state,