File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
src/app/api/usage/[connectionId] Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1- import { getProviderConnectionById , updateProviderConnection } from "@/lib/localDb" ;
1+ import { getProviderConnectionById , updateProviderConnection , resolveProxyForConnection } from "@/lib/localDb" ;
22import { getMachineId } from "@/shared/utils/machine" ;
33import { getUsageForProvider } from "@omniroute/open-sse/services/usage.ts" ;
44import { getExecutor } from "@omniroute/open-sse/executors/index.ts" ;
55import { syncToCloud } from "@/lib/cloudSync" ;
6+ import { runWithProxyContext } from "@omniroute/open-sse/utils/proxyFetch.ts" ;
67
78/**
89 * Sync to cloud if enabled
@@ -139,8 +140,13 @@ export async function GET(request: Request, { params }: { params: Promise<{ conn
139140 ) ;
140141 }
141142
142- // Fetch usage from provider API
143- const usage = await getUsageForProvider ( connection ) ;
143+ // Resolve proxy for this connection (key → combo → provider → global → direct)
144+ const proxyInfo = await resolveProxyForConnection ( connectionId ) ;
145+
146+ // Fetch usage from provider API, wrapped in proxy context
147+ const usage = await runWithProxyContext ( proxyInfo ?. proxy || null , ( ) =>
148+ getUsageForProvider ( connection )
149+ ) ;
144150 return Response . json ( usage ) ;
145151 } catch ( error ) {
146152 console . error ( "[Usage API] Error fetching usage:" , error ) ;
You can’t perform that action at this time.
0 commit comments