From 6aad7ee8b6f9c313db9cf41a7e19640716c37865 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Sat, 16 Nov 2024 11:26:41 +1100 Subject: [PATCH] Allow remote dev to be switched on/off (#1558) * Allow remote dev to be switched on/off * nit - Docs --- .env_example | 5 +++++ README.md | 2 ++ vite.config.mts | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env_example b/.env_example index 7bebc6936..b7f049aa9 100644 --- a/.env_example +++ b/.env_example @@ -6,6 +6,11 @@ PLAYWRIGHT_TEST_URL=http://localhost:5173 # Note: localhost:8188 does not work. DEV_SERVER_COMFYUI_URL=http://127.0.0.1:8188 +# Allow dev server access from remote IP addresses. +# If true, the vite dev server will listen on all addresses, including LAN +# and public addresses. +VITE_REMOTE_DEV=false + # The target ComfyUI checkout directory to deploy the frontend code to. # The dist directory will be copied to {DEPLOY_COMFYUI_DIR}/custom_web_versions/main/dev # Add `--front-end-root {DEPLOY_COMFYUI_DIR}/custom_web_versions/main/dev` diff --git a/README.md b/README.md index 3861420df..7224f14a5 100644 --- a/README.md +++ b/README.md @@ -431,6 +431,8 @@ core extensions will be loaded. #### Access dev server on touch devices +Enable remote access to the dev server by setting `VITE_REMOTE_DEV` in `.env` to `true`. + After you start the dev server, you should see following logs: ``` diff --git a/vite.config.mts b/vite.config.mts index 616c5c157..7d454479b 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -11,6 +11,8 @@ dotenv.config() const IS_DEV = process.env.NODE_ENV === 'development' 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' interface ShimResult { code: string @@ -94,7 +96,7 @@ const DEV_SERVER_COMFYUI_URL = process.env.DEV_SERVER_COMFYUI_URL || 'http://127 export default defineConfig({ base: '', server: { - host: '0.0.0.0', + host: VITE_REMOTE_DEV ? '0.0.0.0' : undefined, proxy: { '/internal': { target: DEV_SERVER_COMFYUI_URL,