mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
fix: don't use SPA route pathname as router base
When user lands directly on a SPA route like /connect, the previous logic set the router base to /connect, causing the /connect route to map to /connect/connect (and similarly for any deep-linked SPA route). A deploy directory pathname always ends with /; SPA route pathnames don't. Use the trailing slash as the discriminator: keep pathname as base when it ends with / (reverse-proxy subpath case), otherwise fall back to BASE_URL. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,13 +29,17 @@ const isFileProtocol = window.location.protocol === 'file:'
|
||||
* 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/
|
||||
* - Standard web: a deploy directory pathname ends with `/`
|
||||
* (e.g. `/ComfyUI/`) — use it as base to support reverse-proxy subpaths.
|
||||
* A SPA route pathname does not end with `/` (e.g. `/connect`) — fall back
|
||||
* to BASE_URL so the route doesn't get appended to itself.
|
||||
*/
|
||||
function getBasePath(): string {
|
||||
if (isDesktop) return '/'
|
||||
if (isCloud) return import.meta.env?.BASE_URL || '/'
|
||||
return window.location.pathname
|
||||
const pathname = window.location.pathname
|
||||
if (pathname.endsWith('/')) return pathname
|
||||
return import.meta.env?.BASE_URL || '/'
|
||||
}
|
||||
|
||||
const basePath = getBasePath()
|
||||
|
||||
Reference in New Issue
Block a user