Skip to content

Commit 42803a0

Browse files
fix: use env var for Vite dev server host in Docker
- Make VITE_DEV_SERVER_HOST configurable via environment variable - Pass 'vite' hostname to Django web service in docker-compose - Remove unused env var from vite service - Defaults to 'localhost' for non-Docker development
1 parent 32d5aeb commit 42803a0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

template/config/settings/base.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ DJANGO_VITE = {
252252
"dev_mode": DEBUG,
253253
"manifest_path": BASE_DIR / "static" / "dist" / "manifest.json",
254254
"static_url_prefix": "dist/",
255-
"dev_server_host": "localhost",
255+
"dev_server_host": env("VITE_DEV_SERVER_HOST", default="localhost"),
256256
"dev_server_port": 5173,
257257
}
258258
}

template/docker-compose.yml.jinja

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ services:
2626
- EMAIL_PORT=1025
2727
{% if dependency_manager == 'uv' %}
2828
- UV_NO_CACHE=1
29+
{% endif %}
30+
{% if frontend_bundling == 'vite' %}
31+
- VITE_DEV_SERVER_HOST=vite
2932
{% endif %}
3033
env_file:
3134
- .env
@@ -76,8 +79,6 @@ services:
7679
ports:
7780
- "5173:5173"
7881
command: sh -c "npm install && npm run dev"
79-
environment:
80-
- VITE_DEV_SERVER_HOST=0.0.0.0
8182
{% endif %}
8283
{% if background_tasks in ['temporal', 'both'] %}
8384

0 commit comments

Comments
 (0)