Spaces:
Sleeping
Sleeping
Lê Phi Nam commited on
Commit ·
974325b
1
Parent(s): bdef142
Fix API URL: use window.location.origin for Docker deployment
Browse files- Dockerfile +7 -1
Dockerfile
CHANGED
|
@@ -13,6 +13,12 @@ RUN bun install --frozen-lockfile
|
|
| 13 |
|
| 14 |
# Build static files (output lands in /app/frontend/dist)
|
| 15 |
COPY frontend/ ./frontend/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
RUN bun run --cwd frontend build
|
| 17 |
|
| 18 |
# ==========================================
|
|
@@ -31,7 +37,7 @@ ENV UV_SYSTEM_PYTHON=1
|
|
| 31 |
ENV HF_HOME=$HOME/app/omnivoice_data/huggingface
|
| 32 |
# Allow bare imports
|
| 33 |
ENV PYTHONPATH=$HOME/app/backend
|
| 34 |
-
# Allow all origins (HF Spaces
|
| 35 |
ENV OMNIVOICE_ALLOWED_ORIGINS="*"
|
| 36 |
# Bind to 0.0.0.0 for Docker networking
|
| 37 |
ENV OMNIVOICE_BIND_HOST="0.0.0.0"
|
|
|
|
| 13 |
|
| 14 |
# Build static files (output lands in /app/frontend/dist)
|
| 15 |
COPY frontend/ ./frontend/
|
| 16 |
+
|
| 17 |
+
# For Docker deployment, frontend and backend share the same origin.
|
| 18 |
+
# Patch client.ts to default to same-origin (window.location.origin) instead
|
| 19 |
+
# of hardcoded 127.0.0.1:3900, so all API/WebSocket calls go to the right host.
|
| 20 |
+
RUN sed -i "s|viteEnv.VITE_API_URL || \`http://127.0.0.1:\${_port}\`|viteEnv.VITE_API_URL || (typeof window !== 'undefined' \&\& window.location ? window.location.origin : '')|" /app/frontend/src/api/client.ts
|
| 21 |
+
|
| 22 |
RUN bun run --cwd frontend build
|
| 23 |
|
| 24 |
# ==========================================
|
|
|
|
| 37 |
ENV HF_HOME=$HOME/app/omnivoice_data/huggingface
|
| 38 |
# Allow bare imports
|
| 39 |
ENV PYTHONPATH=$HOME/app/backend
|
| 40 |
+
# Allow all origins (HF Spaces iframe embedding)
|
| 41 |
ENV OMNIVOICE_ALLOWED_ORIGINS="*"
|
| 42 |
# Bind to 0.0.0.0 for Docker networking
|
| 43 |
ENV OMNIVOICE_BIND_HOST="0.0.0.0"
|