From d21d89f2508be35126d6020e2978a65f053caafb Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Wed, 20 May 2026 07:20:09 +0100 Subject: [PATCH] refactor: simplify API request URL handling by utilizing the full URL from the input directly --- apps/dashboard/src/lib/utils/services/api/index.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/dashboard/src/lib/utils/services/api/index.ts b/apps/dashboard/src/lib/utils/services/api/index.ts index 189d7ed1..9d2e7128 100644 --- a/apps/dashboard/src/lib/utils/services/api/index.ts +++ b/apps/dashboard/src/lib/utils/services/api/index.ts @@ -66,14 +66,10 @@ class ApiClient { private async makeRequest(input: RequestInfo | URL, requestConfig: RequestConfig = {}): Promise { const { timeout = this.config.timeout, retries = this.config.retries, ...fetchConfig } = requestConfig; - const inputUrl = typeof input === 'string' ? input : input.toString(); - const inputUrlObject = new URL(inputUrl, 'http://_'); - - // We are dynamically always getting the base URL to make sure we are getting the right url for the right environment. - // For example, when you use classroomio.account.$get(), on the server in a docker container, we want it to hit the api container directly instead of hitting the public url which is extra bandwidth. - // However when on the client, we want it to hit the public url which still points to the api container but this time with some bandwidth. - const base = (getRequestBaseUrl() ?? this.config.baseURL)?.replace(/\/$/, '') ?? ''; - const fullUrl = `${base}${inputUrlObject.pathname}${inputUrlObject.search}`; + // The Hono RPC client already builds a full URL using the base it was + // constructed with (PRIVATE_SERVER_URL on the server, `${origin}/proxy` + // in the browser — see `getRequestBaseUrl()` above). Forward it as-is. + const fullUrl = typeof input === 'string' ? input : input.toString(); // Prepare headers const headers = new Headers(fetchConfig.headers);