[backport core/1.33] fix: subpath routing for reverse proxy, embedded frontends, nginx/apache subpath hosting, etc. (like SwarmUI) (#7116)

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 <cbyrne@comfy.org>
This commit is contained in:
Comfy Org PR Bot
2025-12-03 11:28:12 +09:00
committed by GitHub
parent cb50a45a80
commit b24d155bcd

View File

@@ -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()