mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 06:47:33 +00:00
feat: Configure vite dev server for staging cloud testing
- Hardcode DEV_SERVER_COMFYUI_URL to staging cloud URL - Enable Vue DevTools by default for better DX - Add SSL certificate handling for all proxy endpoints - Add optional API key support via STAGING_API_KEY env var - Bypass multi-user auth to simulate single-user mode - Add comments explaining the staging setup This allows developers to test frontend changes against the staging cloud backend by simply running npm run dev without any env configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -17,10 +17,21 @@ const SHOULD_MINIFY = process.env.ENABLE_MINIFY === 'true'
|
||||
// vite dev server will listen on all addresses, including LAN and public addresses
|
||||
const VITE_REMOTE_DEV = process.env.VITE_REMOTE_DEV === 'true'
|
||||
const DISABLE_TEMPLATES_PROXY = process.env.DISABLE_TEMPLATES_PROXY === 'true'
|
||||
const DISABLE_VUE_PLUGINS = process.env.DISABLE_VUE_PLUGINS === 'true'
|
||||
const DISABLE_VUE_PLUGINS = false // Always enable Vue DevTools for development
|
||||
|
||||
const DEV_SERVER_COMFYUI_URL =
|
||||
process.env.DEV_SERVER_COMFYUI_URL || 'http://127.0.0.1:8188'
|
||||
// Hardcoded to staging cloud for testing frontend changes against cloud backend
|
||||
const DEV_SERVER_COMFYUI_URL = 'https://stagingcloud.comfy.org'
|
||||
// To use local backend, change to: 'http://127.0.0.1:8188'
|
||||
|
||||
// Optional: Add API key to .env as STAGING_API_KEY if needed for authentication
|
||||
const addAuthHeaders = (proxy: any) => {
|
||||
proxy.on('proxyReq', (proxyReq: any, _req: any, _res: any) => {
|
||||
const apiKey = process.env.STAGING_API_KEY
|
||||
if (apiKey) {
|
||||
proxyReq.setHeader('X-API-KEY', apiKey)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
base: '',
|
||||
@@ -28,16 +39,31 @@ export default defineConfig({
|
||||
host: VITE_REMOTE_DEV ? '0.0.0.0' : undefined,
|
||||
proxy: {
|
||||
'/internal': {
|
||||
target: DEV_SERVER_COMFYUI_URL
|
||||
target: DEV_SERVER_COMFYUI_URL,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
configure: addAuthHeaders
|
||||
},
|
||||
|
||||
'/api': {
|
||||
target: DEV_SERVER_COMFYUI_URL,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
configure: (proxy, _options) => {
|
||||
addAuthHeaders(proxy)
|
||||
},
|
||||
// Return empty array for extensions API as these modules
|
||||
// are not on vite's dev server.
|
||||
bypass: (req, res, _options) => {
|
||||
if (req.url === '/api/extensions') {
|
||||
res.end(JSON.stringify([]))
|
||||
return false // Return false to indicate request is handled
|
||||
}
|
||||
// Bypass multi-user auth check from staging
|
||||
if (req.url === '/api/users') {
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.end(JSON.stringify({})) // Return empty object to simulate single-user mode
|
||||
return false // Return false to indicate request is handled
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -45,29 +71,39 @@ export default defineConfig({
|
||||
|
||||
'/ws': {
|
||||
target: DEV_SERVER_COMFYUI_URL,
|
||||
ws: true
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
configure: addAuthHeaders
|
||||
},
|
||||
|
||||
'/workflow_templates': {
|
||||
target: DEV_SERVER_COMFYUI_URL
|
||||
target: DEV_SERVER_COMFYUI_URL,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
configure: addAuthHeaders
|
||||
},
|
||||
|
||||
// Proxy extension assets (images/videos) under /extensions to the ComfyUI backend
|
||||
'/extensions': {
|
||||
target: DEV_SERVER_COMFYUI_URL,
|
||||
changeOrigin: true
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
|
||||
// Proxy docs markdown from backend
|
||||
'/docs': {
|
||||
target: DEV_SERVER_COMFYUI_URL,
|
||||
changeOrigin: true
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
|
||||
...(!DISABLE_TEMPLATES_PROXY
|
||||
? {
|
||||
'/templates': {
|
||||
target: DEV_SERVER_COMFYUI_URL
|
||||
target: DEV_SERVER_COMFYUI_URL,
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
}
|
||||
}
|
||||
: {}),
|
||||
|
||||
Reference in New Issue
Block a user