|
@@ -7,9 +7,12 @@ import { getCorsHeaders, handleCorsPreflightRequest } from '../_shared/cors.ts';
|
|
|
|
|
|
|
|
// Handle OPTIONS requests BEFORE wrapping with error handler to avoid timeouts
|
|
// Handle OPTIONS requests BEFORE wrapping with error handler to avoid timeouts
|
|
|
serve(async (req) => {
|
|
serve(async (req) => {
|
|
|
|
|
+ const origin = req.headers.get('Origin') || undefined;
|
|
|
|
|
+ const corsHeaders = getCorsHeaders(origin, ['PUT', 'DELETE']);
|
|
|
|
|
+
|
|
|
// Fast-path for OPTIONS requests
|
|
// Fast-path for OPTIONS requests
|
|
|
if (req.method === 'OPTIONS') {
|
|
if (req.method === 'OPTIONS') {
|
|
|
- return handleCorsPreflightRequest(['PUT', 'DELETE'])
|
|
|
|
|
|
|
+ return handleCorsPreflightRequest(origin, ['PUT', 'DELETE'])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Wrap all other requests with error handler
|
|
// Wrap all other requests with error handler
|