Przeglądaj źródła

fix(cors): add prominent comment to preserve DELETE and PATCH methods

Added explicit comment warning to keep DELETE and PATCH methods in the
CORS defaultMethods array, preventing future accidental removals that
cause CORS errors for custom-content-delete and custom-urls operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fszontagh 4 miesięcy temu
rodzic
commit
082b0a1ddb
1 zmienionych plików z 12 dodań i 2 usunięć
  1. 12 2
      supabase/functions/_shared/cors.ts

+ 12 - 2
supabase/functions/_shared/cors.ts

@@ -38,8 +38,18 @@ export function getCorsHeaders(requestOrigin?: string, additionalMethods: string
     allowOrigin = allowedOrigins[0] || '*';
     allowOrigin = allowedOrigins[0] || '*';
   }
   }
 
 
-  // Default methods - include PATCH and DELETE for API operations
-  const defaultMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'];
+  // IMPORTANT: Keep all these methods in the list!
+  // DELETE is required for custom-content-delete and other delete operations.
+  // PATCH is required for custom-urls and update operations.
+  // Removing any method will cause CORS errors in the browser.
+  const defaultMethods = [
+    'GET',
+    'POST',
+    'PUT',
+    'PATCH',
+    'DELETE',
+    'OPTIONS'
+  ];
   const allMethods = [...new Set([...defaultMethods, ...additionalMethods])];
   const allMethods = [...new Set([...defaultMethods, ...additionalMethods])];
 
 
   return {
   return {