api: cors in middleware (#1493)

This commit is contained in:
Huang Xin
2025-06-29 23:00:52 +08:00
committed by GitHub
parent d5d0a9abd3
commit 280cb75ca4
4 changed files with 33 additions and 8 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ import { getStripe } from '@/libs/stripe/server';
import { createSupabaseAdminClient } from './supabase';
import { UserPlan } from '@/types/user';
export const createSubscription = async (
export const createOrUpdateSubscription = async (
userId: string,
customerId: string,
subscriptionId: string,
@@ -58,7 +58,7 @@ export const createSubscription = async (
await supabase
.from('plans')
.update({
plan: plan,
plan: ['active', 'trialing'].includes(subscription.status) ? plan : 'free',
status: subscription.status,
})
.eq('id', userId);