From 01ea0de4b326f9d910b3288ac54d13403694bbc5 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 6 Dec 2025 17:32:34 -0300 Subject: [PATCH] fix: decouple DEBUG env variable from vite dev server --- README.md | 7 +++++-- app/WYGIWYH/settings.py | 6 +++--- frontend/vite.config.js | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dbeb67b..9835c2b 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ To create the first user, open the container's console using Unraid's UI, by cli | variable | type | default | explanation | |-------------------------------|-------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| INTERNAL_PORT | int | 8000 | The port on which the app listens on. Defaults to 8000 if not set. | +| INTERNAL_PORT | int | 8000 | The port on which the app listens on. Defaults to 8000 if not set. | | DJANGO_ALLOWED_HOSTS | string | localhost 127.0.0.1 | A list of space separated domains and IPs representing the host/domain names that WYGIWYH site can serve. [Click here](https://docs.djangoproject.com/en/5.1/ref/settings/#allowed-hosts) for more details | | HTTPS_ENABLED | true\|false | false | Whether to use secure cookies. If this is set to true, the cookie will be marked as “secure”, which means browsers may ensure that the cookie is only sent under an HTTPS connection | | URL | string | http://localhost http://127.0.0.1 | A list of space separated domains and IPs (with the protocol) representing the trusted origins for unsafe requests (e.g. POST). [Click here](https://docs.djangoproject.com/en/5.1/ref/settings/#csrf-trusted-origins ) for more details | @@ -145,7 +145,10 @@ To create the first user, open the container's console using Unraid's UI, by cli | DEMO | true\|false | false | If demo mode is enabled. | | ADMIN_EMAIL | string | None | Automatically creates an admin account with this email. Must have `ADMIN_PASSWORD` also set. | | ADMIN_PASSWORD | string | None | Automatically creates an admin account with this password. Must have `ADMIN_EMAIL` also set. | -| CHECK_FOR_UPDATES | bool | true | Check and notify users about new versions. The check is done by doing a single query to Github's API every 12 hours. | +| CHECK_FOR_UPDATES | true\|false | true | Check and notify users about new versions. The check is done by doing a single query to Github's API every 12 hours. | +| DJANGO_VITE_DEV_MODE | true\|false | false | Enables Vite dev server mode for frontend development. When true, assets are served from Vite's dev server instead of the build manifest. For development only! | +| DJANGO_VITE_DEV_SERVER_PORT | int | 5173 | The port where Vite's dev server is running. Only used when DJANGO_VITE_DEV_MODE is true. For development only! | +| DJANGO_VITE_DEV_SERVER_HOST | string | localhost | The host where Vite's dev server is running. Only used when DJANGO_VITE_DEV_MODE is true. For development only! | ## OIDC Configuration diff --git a/app/WYGIWYH/settings.py b/app/WYGIWYH/settings.py index b1912b3..8461121 100644 --- a/app/WYGIWYH/settings.py +++ b/app/WYGIWYH/settings.py @@ -319,9 +319,9 @@ CACHES = { DJANGO_VITE_ASSETS_PATH = STATIC_ROOT DJANGO_VITE_MANIFEST_PATH = DJANGO_VITE_ASSETS_PATH / "manifest.json" -DJANGO_VITE_DEV_MODE = DEBUG -DJANGO_VITE_DEV_SERVER_PORT = 5173 -DJANGO_VITE_DEV_SERVER_HOST = "localhost" +DJANGO_VITE_DEV_MODE = os.getenv("DJANGO_VITE_DEV_MODE", "false").lower() == "true" +DJANGO_VITE_DEV_SERVER_PORT = int(os.getenv("DJANGO_VITE_DEV_SERVER_PORT", "5173")) +DJANGO_VITE_DEV_SERVER_HOST = os.getenv("DJANGO_VITE_DEV_SERVER_HOST", "localhost") # Default primary key field type # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 2a5779b..b8eb729 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -29,7 +29,7 @@ export default defineConfig({ server: { host: '0.0.0.0', - port: 5173, + port: parseInt(process.env.VITE_DEV_SERVER_PORT || '5173'), open: false, watch: { usePolling: true, @@ -37,7 +37,7 @@ export default defineConfig({ }, hmr: false, cors: true, - origin: 'http://localhost:5173' + origin: `http://${process.env.VITE_DEV_SERVER_HOST || 'localhost'}:${process.env.VITE_DEV_SERVER_PORT || '5173'}` }, resolve: {