From e1f707ffe2bfb20ebbc29740f59bf81faddfba93 Mon Sep 17 00:00:00 2001 From: Jin Yi Date: Mon, 3 Nov 2025 02:45:45 +0900 Subject: [PATCH] fix: Use environment-specific log API endpoints for Cloud and OSS (#6539) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem 401 authentication errors were persistently occurring when calling log-related APIs in the Cloud environment. ## Root Cause - Frontend was calling `/internal/logs/*` endpoints in all environments - Cloud backend provides public APIs at `/api/logs/*` (no authentication required) - OSS (open source) backend uses `/internal/logs/*` paths - This caused Cloud to call non-existent paths → resulting in 401 errors ## Solution Modified to use appropriate API endpoints based on environment using the `isCloud` flag: - Cloud environment: Use `/api/logs/*` - OSS environment: Use `/internal/logs/*` ## Changes - `getLogs()`: Added environment-specific URL branching - `getRawLogs()`: Added environment-specific URL branching - `subscribeLogs()`: Added environment-specific URL branching ## Testing - [x] Verified log functionality works correctly in local (OSS) environment - [x] Confirmed 401 errors are resolved in Cloud environment ## Related Issues This resolves the 401 errors tracked in Sentry for log API endpoints. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6539-fix-Use-environment-specific-log-API-endpoints-for-Cloud-and-OSS-29f6d73d365081da9e77f8b55556ca81) by [Unito](https://www.unito.io) --- src/scripts/api.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/scripts/api.ts b/src/scripts/api.ts index e43bd39aa..84d491bde 100644 --- a/src/scripts/api.ts +++ b/src/scripts/api.ts @@ -1135,15 +1135,22 @@ export class ComfyApi extends EventTarget { } async getLogs(): Promise { - return (await axios.get(this.internalURL('/logs'))).data + const url = isCloud ? this.apiURL('/logs') : this.internalURL('/logs') + return (await axios.get(url)).data } async getRawLogs(): Promise { - return (await axios.get(this.internalURL('/logs/raw'))).data + const url = isCloud + ? this.apiURL('/logs/raw') + : this.internalURL('/logs/raw') + return (await axios.get(url)).data } async subscribeLogs(enabled: boolean): Promise { - return await axios.patch(this.internalURL('/logs/subscribe'), { + const url = isCloud + ? this.apiURL('/logs/subscribe') + : this.internalURL('/logs/subscribe') + return await axios.patch(url, { enabled, clientId: this.clientId })