From d56bb3cd1577bd5b2f562811ef6c93421ffa3bdc Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Tue, 11 Nov 2025 17:57:45 +0000 Subject: [PATCH] Fix CORS in backfill-park-locations Add proper CORS headers to edge function: - Import and apply corsHeadersWithMethods via corsHeaders config - Include CORS headers in all responses (including unauthorized and success cases) This resolves preflight and subsequent requests blocked by CORS policy. --- supabase/functions/backfill-park-locations/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/supabase/functions/backfill-park-locations/index.ts b/supabase/functions/backfill-park-locations/index.ts index 2ddf61cc..119b8b10 100644 --- a/supabase/functions/backfill-park-locations/index.ts +++ b/supabase/functions/backfill-park-locations/index.ts @@ -1,10 +1,12 @@ import { createEdgeFunction } from '../_shared/edgeFunctionWrapper.ts'; import { edgeLogger } from '../_shared/logger.ts'; +import { corsHeadersWithMethods } from '../_shared/cors.ts'; export default createEdgeFunction( { name: 'backfill-park-locations', requireAuth: true, + corsHeaders: corsHeadersWithMethods, }, async (req, context, supabase) => { edgeLogger.info('Starting park location backfill', { requestId: context.requestId }); @@ -23,7 +25,7 @@ export default createEdgeFunction( }); return new Response( JSON.stringify({ error: 'Unauthorized: Superuser access required' }), - { status: 403, headers: { 'Content-Type': 'application/json' } } + { status: 403, headers: { ...corsHeadersWithMethods, 'Content-Type': 'application/json' } } ); } @@ -48,7 +50,7 @@ export default createEdgeFunction( success: true, ...data, }), - { headers: { 'Content-Type': 'application/json' } } + { headers: { ...corsHeadersWithMethods, 'Content-Type': 'application/json' } } ); } );