Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(auth): split load evenly between two instances

Gergő Móricz8620bf3d5ec5
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts
index 71d3c43aa..af0a53a71 100644
--- a/apps/api/src/controllers/auth.ts
+++ b/apps/api/src/controllers/auth.ts
@@ -6,7 +6,7 @@ import {
PlanType,
RateLimiterMode,
} from "../types";
-import { supabase_rr_service } from "../services/supabase";
+import { supabase_rr_service, supabase_service } from "../services/supabase";
import { withAuth } from "../lib/withAuth";
import { RateLimiterRedis } from "rate-limiter-flexible";
import { sendNotification } from "../services/notification/email_notification";
@@ -100,7 +100,8 @@ export async function getACUC(
? "auth_credit_usage_chunk_extract"
: "auth_credit_usage_chunk_test_22_credit_pack_n_extract";
while (retries < maxRetries) {
- ({ data, error } = await supabase_rr_service.rpc(
+ const client = Math.random() > 0.5 ? supabase_rr_service : supabase_service;
+ ({ data, error } = await client.rpc(
rpcName,
{ input_key: api_key },
{ get: true },