mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
Fix routing (#929)
* fix router and move graph related parts to GraphView.vue * (fix) add back child element in UnloadWindowConfirmDialog * (cleanup) remove empty callback * (fix) routing issue when base url is not webroot * add back DEV_SERVER_COMFYUI_URL
This commit is contained in:
committed by
Chenlei Hu
parent
5e51ae37cf
commit
9c7ea5bd87
10
.env_example
10
.env_example
@@ -16,4 +16,12 @@ DEPLOY_COMFYUI_DIR=/home/ComfyUI/web
|
|||||||
EXAMPLE_REPO_PATH=tests-ui/ComfyUI_examples
|
EXAMPLE_REPO_PATH=tests-ui/ComfyUI_examples
|
||||||
|
|
||||||
# Whether to enable minification of the frontend code.
|
# Whether to enable minification of the frontend code.
|
||||||
ENABLE_MINIFY=true
|
ENABLE_MINIFY=true
|
||||||
|
|
||||||
|
# ------ ViteJS related env variables ------
|
||||||
|
# Note: the VITE_ prefix is required
|
||||||
|
|
||||||
|
# Frontend base URL
|
||||||
|
# Note: default / is for http://localhost:5173/
|
||||||
|
# Example: /foobar/ will be served as http://localhost:5173/foobar/
|
||||||
|
VITE_BASE_URL=
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
app_title: 'ComfyUI',
|
app_title: 'ComfyUI',
|
||||||
app_version: __COMFYUI_FRONTEND_VERSION__
|
app_version: __COMFYUI_FRONTEND_VERSION__,
|
||||||
|
base_url: import.meta.env.VITE_BASE_URL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
import config from '@/config'
|
||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import LayoutDefault from '@/views/layouts/LayoutDefault.vue'
|
import LayoutDefault from '@/views/layouts/LayoutDefault.vue'
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(),
|
history: createWebHistory(config.base_url),
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ interface QueuePromptRequestBody {
|
|||||||
class ComfyApi extends EventTarget {
|
class ComfyApi extends EventTarget {
|
||||||
#registered = new Set()
|
#registered = new Set()
|
||||||
api_host: string
|
api_host: string
|
||||||
api_base: string
|
|
||||||
initialClientId: string
|
initialClientId: string
|
||||||
user: string
|
user: string
|
||||||
socket?: WebSocket
|
socket?: WebSocket
|
||||||
@@ -43,21 +42,21 @@ class ComfyApi extends EventTarget {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this.api_host = location.host
|
this.api_host = window.location.host
|
||||||
this.api_base = location.pathname.split('/').slice(0, -1).join('/')
|
console.log('Running on', this.api_host)
|
||||||
this.initialClientId = sessionStorage.getItem('clientId')
|
this.initialClientId = sessionStorage.getItem('clientId')
|
||||||
}
|
}
|
||||||
|
|
||||||
internalURL(route: string): string {
|
internalURL(route: string): string {
|
||||||
return this.api_base + '/internal' + route
|
return '/internal' + route
|
||||||
}
|
}
|
||||||
|
|
||||||
apiURL(route: string): string {
|
apiURL(route: string): string {
|
||||||
return this.api_base + '/api' + route
|
return '/api' + route
|
||||||
}
|
}
|
||||||
|
|
||||||
fileURL(route: string): string {
|
fileURL(route: string): string {
|
||||||
return this.api_base + route
|
return route
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchApi(route: string, options?: RequestInit) {
|
fetchApi(route: string, options?: RequestInit) {
|
||||||
@@ -113,7 +112,7 @@ class ComfyApi extends EventTarget {
|
|||||||
existingSession = '?clientId=' + existingSession
|
existingSession = '?clientId=' + existingSession
|
||||||
}
|
}
|
||||||
this.socket = new WebSocket(
|
this.socket = new WebSocket(
|
||||||
`ws${window.location.protocol === 'https:' ? 's' : ''}://${this.api_host}${this.api_base}/ws${existingSession}`
|
`ws${window.location.protocol === 'https:' ? 's' : ''}://${this.api_host}/ws${existingSession}`
|
||||||
)
|
)
|
||||||
this.socket.binaryType = 'arraybuffer'
|
this.socket.binaryType = 'arraybuffer'
|
||||||
|
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ export const useNodeFrequencyStore = defineStore('nodeFrequency', () => {
|
|||||||
const loadNodeFrequencies = async () => {
|
const loadNodeFrequencies = async () => {
|
||||||
if (!isLoaded.value) {
|
if (!isLoaded.value) {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('/assets/sorted-custom-node-map.json')
|
const response = await axios.get('assets/sorted-custom-node-map.json')
|
||||||
nodeFrequencyLookup.value = response.data
|
nodeFrequencyLookup.value = response.data
|
||||||
isLoaded.value = true
|
isLoaded.value = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -90,9 +90,10 @@ function getModuleName(id: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DEV_SERVER_COMFYUI_URL = process.env.DEV_SERVER_COMFYUI_URL || 'http://127.0.0.1:8188'
|
const DEV_SERVER_COMFYUI_URL = process.env.DEV_SERVER_COMFYUI_URL || 'http://127.0.0.1:8188'
|
||||||
|
const VITE_BASE_URL = process.env.VITE_BASE_URL || '/'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: '',
|
base: VITE_BASE_URL,
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/internal': {
|
'/internal': {
|
||||||
|
|||||||
Reference in New Issue
Block a user