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.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-11 17:57:45 +00:00
parent 9b1c2415b0
commit d56bb3cd15

View File

@@ -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' } }
);
}
);