mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 06:19:58 +00:00
[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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user