@@ -27,8 +27,14 @@ const GENERATE_SOURCEMAP = process.env.GENERATE_SOURCEMAP !== 'false'
2727const DEV_SERVER_COMFYUI_ENV_URL = process . env . DEV_SERVER_COMFYUI_URL
2828const IS_CLOUD_URL = DEV_SERVER_COMFYUI_ENV_URL ?. includes ( '.comfy.org' )
2929
30- const DISTRIBUTION = ( process . env . DISTRIBUTION ||
31- ( IS_CLOUD_URL ? 'cloud' : 'localhost' ) ) as 'desktop' | 'localhost' | 'cloud'
30+ const DISTRIBUTION : 'desktop' | 'localhost' | 'cloud' =
31+ process . env . DISTRIBUTION === 'desktop' ||
32+ process . env . DISTRIBUTION === 'localhost' ||
33+ process . env . DISTRIBUTION === 'cloud'
34+ ? process . env . DISTRIBUTION
35+ : IS_CLOUD_URL
36+ ? 'cloud'
37+ : 'localhost'
3238
3339// Disable Vue DevTools for production cloud distribution
3440const DISABLE_VUE_PLUGINS =
@@ -43,39 +49,9 @@ const DEV_SEVER_FALLBACK_URL =
4349const DEV_SERVER_COMFYUI_URL =
4450 DEV_SERVER_COMFYUI_ENV_URL || DEV_SEVER_FALLBACK_URL
4551
46- // Optional: Add API key to .env as STAGING_API_KEY if needed for cloud authentication
47- const addAuthHeaders = ( proxy : any ) => {
48- proxy . on ( 'proxyReq' , ( proxyReq : any , _req : any , _res : any ) => {
49- const apiKey = process . env . STAGING_API_KEY
50- if ( apiKey ) {
51- proxyReq . setHeader ( 'X-API-KEY' , apiKey )
52- }
53- } )
54- }
55-
56- // Cloud endpoint configuration overrides
57- const cloudSecureConfig =
58- DISTRIBUTION === 'cloud'
59- ? {
60- secure : false
61- }
62- : { }
63-
52+ // Cloud proxy configuration
6453const cloudProxyConfig =
65- DISTRIBUTION === 'cloud'
66- ? {
67- ...cloudSecureConfig ,
68- changeOrigin : true
69- }
70- : { }
71-
72- const cloudProxyConfigWithAuth =
73- DISTRIBUTION === 'cloud'
74- ? {
75- ...cloudProxyConfig ,
76- configure : addAuthHeaders
77- }
78- : { }
54+ DISTRIBUTION === 'cloud' ? { secure : false , changeOrigin : true } : { }
7955
8056const BUILD_FLAGS = {
8157 REQUIRE_SUBSCRIPTION : process . env . REQUIRE_SUBSCRIPTION === 'true'
@@ -105,12 +81,12 @@ export default defineConfig({
10581 proxy : {
10682 '/internal' : {
10783 target : DEV_SERVER_COMFYUI_URL ,
108- ...cloudProxyConfigWithAuth
84+ ...cloudProxyConfig
10985 } ,
11086
11187 '/api' : {
11288 target : DEV_SERVER_COMFYUI_URL ,
113- ...cloudProxyConfigWithAuth ,
89+ ...cloudProxyConfig ,
11490 bypass : ( req , res , _options ) => {
11591 // Return empty array for extensions API as these modules
11692 // are not on vite's dev server.
@@ -133,26 +109,24 @@ export default defineConfig({
133109 '/ws' : {
134110 target : DEV_SERVER_COMFYUI_URL ,
135111 ws : true ,
136- ...cloudProxyConfigWithAuth
112+ ...cloudProxyConfig
137113 } ,
138114
139115 '/workflow_templates' : {
140116 target : DEV_SERVER_COMFYUI_URL ,
141- ...cloudProxyConfigWithAuth
117+ ...cloudProxyConfig
142118 } ,
143119
144- // Proxy extension assets (images/videos) under /extensions to the ComfyUI backend
145120 '/extensions' : {
146121 target : DEV_SERVER_COMFYUI_URL ,
147122 changeOrigin : true ,
148- ...cloudSecureConfig
123+ ...cloudProxyConfig
149124 } ,
150125
151- // Proxy docs markdown from backend
152126 '/docs' : {
153127 target : DEV_SERVER_COMFYUI_URL ,
154128 changeOrigin : true ,
155- ...cloudSecureConfig
129+ ...cloudProxyConfig
156130 } ,
157131
158132 ...( ! DISABLE_TEMPLATES_PROXY
0 commit comments