Skip to content

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

fix(api): remove dedicated ACUC Supabase client for consistency (#2991)

firecrawl-spring[bot]6a5c5dfe432d
diff --git a/apps/api/src/config.ts b/apps/api/src/config.ts
index 697f95858..e82b16789 100644
--- a/apps/api/src/config.ts
+++ b/apps/api/src/config.ts
@@ -70,8 +70,6 @@ const configSchema = z.object({
SUPABASE_ANON_TOKEN: z.string().optional(),
SUPABASE_SERVICE_TOKEN: z.string().optional(),
SUPABASE_REPLICA_URL: z.string().optional(),
- SUPABASE_ACUC_URL: z.string().optional(),
- SUPABASE_ACUC_SERVICE_TOKEN: z.string().optional(),
INDEX_SUPABASE_URL: z.string().optional(),
INDEX_SUPABASE_SERVICE_TOKEN: z.string().optional(),
SEARCH_INDEX_SUPABASE_URL: z.string().optional(),
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts
index 1a729a68b..b212893e8 100644
--- a/apps/api/src/controllers/auth.ts
+++ b/apps/api/src/controllers/auth.ts
@@ -10,7 +10,6 @@ import { getRateLimiter } from "../services/rate-limiter";
import { deleteKey, getValue, setValue } from "../services/redis";
import { redlock } from "../services/redlock";
import {
- supabase_acuc_only_service,
supabase_rr_service,
supabase_service,
} from "../services/supabase";
@@ -157,7 +156,7 @@ export async function getACUC(
return acuc;
}
- if (config.USE_DB_AUTHENTICATION !== true && !config.SUPABASE_ACUC_URL) {
+ if (config.USE_DB_AUTHENTICATION !== true) {
const acuc = mockACUC();
acuc.is_extract = isExtract;
return acuc;
@@ -178,11 +177,9 @@ export async function getACUC(
let retries = 0;
const maxRetries = 5;
while (retries < maxRetries) {
- const client = !!config.SUPABASE_ACUC_URL
- ? supabase_acuc_only_service
- : Math.random() > 2 / 3
- ? supabase_rr_service
- : supabase_service;
+ const client = Math.random() > 2 / 3
+ ? supabase_rr_service
+ : supabase_service;
({ data, error } = await client.rpc(
"auth_credit_usage_chunk_45",
{
@@ -286,7 +283,7 @@ export async function getACUCTeam(
return acuc;
}
- if (config.USE_DB_AUTHENTICATION !== true && !config.SUPABASE_ACUC_URL) {
+ if (config.USE_DB_AUTHENTICATION !== true) {
const acuc = mockACUC();
acuc.is_extract = isExtract;
return acuc;
@@ -308,11 +305,9 @@ export async function getACUCTeam(
const maxRetries = 5;
while (retries < maxRetries) {
- const client = !!config.SUPABASE_ACUC_URL
- ? supabase_acuc_only_service
- : Math.random() > 2 / 3
- ? supabase_rr_service
- : supabase_service;
+ const client = Math.random() > 2 / 3
+ ? supabase_rr_service
+ : supabase_service;
({ data, error } = await client.rpc(
"auth_credit_usage_chunk_45_from_team",
{
@@ -393,10 +388,6 @@ export async function authenticateUser(
res,
mode?: RateLimiterMode,
): Promise<AuthResponse> {
- if (!!config.SUPABASE_ACUC_URL) {
- return supaAuthenticateUser(req, res, mode);
- }
-
return withAuth(supaAuthenticateUser, {
success: true,
chunk: null,
diff --git a/apps/api/src/services/supabase.ts b/apps/api/src/services/supabase.ts
index 7e99131d9..224c58c25 100644
--- a/apps/api/src/services/supabase.ts
+++ b/apps/api/src/services/supabase.ts
@@ -18,8 +18,6 @@ class SupabaseService {
private client: SupabaseClient | null = null;
private rrClient: SupabaseClient | null = null;
- private acucClient: SupabaseClient | null = null;
-
constructor() {
const supabaseUrl = config.SUPABASE_URL;
const supabaseReplicaUrl = config.SUPABASE_REPLICA_URL;
@@ -27,25 +25,6 @@ class SupabaseService {
const useDbAuthentication = config.USE_DB_AUTHENTICATION;
// Only initialize the Supabase client if both URL and Service Token are provided.
if (!useDbAuthentication) {
- if (!!config.SUPABASE_ACUC_URL) {
- const supabaseAcucUrl = config.SUPABASE_ACUC_URL;
- const supabaseAcucServiceToken = config.SUPABASE_ACUC_SERVICE_TOKEN;
- if (!supabaseAcucUrl || !supabaseAcucServiceToken) {
- logger.error(
- "Supabase ACUC environment variables aren't configured correctly. Supabase ACUC client will not be initialized. Fix ENV configuration or disable ACUC with USE_DB_AUTHENTICATION env variable",
- );
- this.acucClient = null;
- } else {
- this.acucClient = createClient(
- supabaseAcucUrl,
- supabaseAcucServiceToken,
- );
- logger.info(
- "Supabase ACUC only client initialized, this is only for request authentication",
- );
- }
- }
-
// Warn the user that Authentication is disabled by setting the client to null
logger.warn(
"Authentication is disabled. Supabase client will not be initialized.",
@@ -76,10 +55,6 @@ class SupabaseService {
getRRClient(): SupabaseClient | null {
return this.rrClient;
}
-
- getACUCOnlyClient(): SupabaseClient | null {
- return this.acucClient;
- }
}
const serv = new SupabaseService();
@@ -122,20 +97,3 @@ export const supabase_rr_service: SupabaseClient = new Proxy(serv, {
},
}) as unknown as SupabaseClient;
-export const supabase_acuc_only_service: SupabaseClient = new Proxy(serv, {
- get: function (target, prop, receiver) {
- const client = target.getACUCOnlyClient();
- // If the Supabase client is not initialized, intercept property access to provide meaningful error feedback.
- if (client === null) {
- return () => {
- throw new Error("Supabase RR client is not configured.");
- };
- }
- // Direct access to SupabaseService properties takes precedence.
- if (prop in target) {
- return Reflect.get(target, prop, receiver);
- }
- // Otherwise, delegate access to the Supabase client.
- return Reflect.get(client, prop, receiver);
- },
-}) as unknown as SupabaseClient;