From b24d155bcd4edb6949f37ba254311db8dfd0cbc9 Mon Sep 17 00:00:00 2001 From: Comfy Org PR Bot Date: Wed, 3 Dec 2025 11:28:12 +0900 Subject: [PATCH] [backport core/1.33] fix: subpath routing for reverse proxy, embedded frontends, nginx/apache subpath hosting, etc. (like SwarmUI) (#7116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport of #7115 to `core/1.33` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7116-backport-core-1-33-fix-subpath-routing-for-reverse-proxy-embedded-frontends-nginx-ap-2be6d73d36508125a7cdf11672203e88) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne --- src/router.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/router.ts b/src/router.ts index bb9addcfd..035f213af 100644 --- a/src/router.ts +++ b/src/router.ts @@ -20,13 +20,17 @@ import { cloudOnboardingRoutes } from './platform/cloud/onboarding/onboardingClo const isFileProtocol = window.location.protocol === 'file:' -// Determine base path for the router -// - Electron: always root -// - Web: rely on Vite's BASE_URL (configured via vite.config `base`) +/** + * Determine base path for the router. + * - Electron: always root + * - Cloud: use Vite's BASE_URL (configured at build time) + * - Standard web (including reverse proxy subpaths): use window.location.pathname + * to support deployments like http://mysite.com/ComfyUI/ + */ function getBasePath(): string { if (isElectron()) return '/' - // Vite injects BASE_URL at build/dev time; default to '/' - return import.meta.env?.BASE_URL || '/' + if (isCloud) return import.meta.env?.BASE_URL || '/' + return window.location.pathname } const basePath = getBasePath()