diff --git a/supabase/functions/detect-location/index.ts b/supabase/functions/detect-location/index.ts index 5acd45b0..c26fef0d 100644 --- a/supabase/functions/detect-location/index.ts +++ b/supabase/functions/detect-location/index.ts @@ -79,7 +79,8 @@ serve(async (req) => { } catch (error) { console.error('Error detecting location:', error); - // Return default (metric) on error + // Return default (metric) with 500 status to indicate error occurred + // This allows proper error monitoring while still providing fallback data const defaultResult: IPLocationResponse = { country: 'Unknown', countryCode: 'XX', @@ -87,13 +88,17 @@ serve(async (req) => { }; return new Response( - JSON.stringify(defaultResult), + JSON.stringify({ + ...defaultResult, + error: error instanceof Error ? error.message : 'Failed to detect location', + fallback: true + }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' }, - status: 200 // Return 200 even on error to provide fallback + status: 500 } ); }