Skip to content

Commit adecd25

Browse files
authored
Fix cloud routing issues caused by incorrect api_base calculation (#6572)
## Summary - Resolves multiple cloud environment issues when accessing `/cloud/user-check` directly - Fixes API routing problems that caused 304 Not Modified errors and JSON parsing failures - Maintains compatibility with subpath deployments for OSS users ## Root Cause The `api_base` was incorrectly calculated as `/cloud` on cloud SPA routes, causing API calls to use wrong paths like `/cloud/api/user` instead of `/api/user`. ## Issues Fixed - ❌ `/cloud/user-check` direct access resulted in infinite loading - ❌ JSON parsing errors: `Unexpected token '<', "<!DOCTYPE "... is not valid JSON` - ❌ 304 Not Modified responses on `/cloud/api/user`, `/cloud/api/settings/onboarding_survey`, `/cloud/api/system_stats` ## Solution Added conditional `api_base` calculation in `ComfyApi` constructor: - **Cloud SPA routes** (`/cloud/*`): Use empty `api_base` → API calls use `/api/*` paths - **Regular deployments**: Keep existing logic → Supports subpath deployments ## Test Plan - [x] Verify `/cloud/user-check` direct access works without infinite loading - [x] Verify all API calls return 200 instead of 304 - [x] Verify OSS subpath deployment compatibility unchanged - [x] Test authentication flow completion 🤖 Generated with [Claude Code](https://claude.ai/code) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6572-Fix-cloud-routing-issues-caused-by-incorrect-api_base-calculation-2a16d73d36508163aeb2cbf6347b427d) by [Unito](https://www.unito.io)
1 parent 2c4280a commit adecd25

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/scripts/api.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,13 @@ export class ComfyApi extends EventTarget {
326326
super()
327327
this.user = ''
328328
this.api_host = location.host
329-
this.api_base = location.pathname.split('/').slice(0, -1).join('/')
329+
const pathname = location.pathname
330+
const isCloudSpaRoute = isCloud && pathname.startsWith('/cloud/')
331+
if (isCloudSpaRoute) {
332+
this.api_base = ''
333+
} else {
334+
this.api_base = pathname.split('/').slice(0, -1).join('/')
335+
}
330336
console.log('Running on', this.api_host)
331337
this.initialClientId = sessionStorage.getItem('clientId')
332338
}

0 commit comments

Comments
 (0)