mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 10:31:13 -05:00
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:
@@ -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' } }
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user