debug: add extensive logging to subscription service
Added debug logs to getAllPlans to diagnose Bad Gateway error. Logs will show in terminal when /admin/plans is accessed.
This commit is contained in:
@@ -27,25 +27,31 @@ export interface UserSubscription {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all subscription plans
|
||||
* Get all subscription plans (admin only via RLS)
|
||||
*/
|
||||
export async function getAllPlans(): Promise<SubscriptionPlan[]> {
|
||||
try {
|
||||
console.log('[getAllPlans] Starting...');
|
||||
const supabase = createServerComponentClient({ cookies });
|
||||
|
||||
// RLS policy will handle admin check
|
||||
const { data, error } = await supabase
|
||||
.from('subscription_plans')
|
||||
.select('*')
|
||||
.order('sort_order', { ascending: true });
|
||||
|
||||
console.log('[getAllPlans] Query result - data:', data?.length, 'error:', error);
|
||||
|
||||
if (error) {
|
||||
console.error('Error fetching plans:', error);
|
||||
console.error('[getAllPlans] Error fetching plans:', error);
|
||||
// Return empty array instead of throwing
|
||||
return [];
|
||||
}
|
||||
|
||||
console.log('[getAllPlans] Returning plans:', data?.length);
|
||||
return data || [];
|
||||
} catch (err) {
|
||||
console.error('Error in getAllPlans:', err);
|
||||
console.error('[getAllPlans] Exception:', err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user