refactor: Update frontend and backend URLs for Docker environment

This commit is contained in:
Peifan Li
2025-11-23 23:42:52 -05:00
parent 1ce8c4b699
commit 7be0cc112c
3 changed files with 28 additions and 6 deletions

View File

@@ -5,8 +5,6 @@ services:
image: franklioxygen/mytube:backend-latest
pull_policy: always
container_name: mytube-backend
ports:
- "5551:5551"
volumes:
- /share/CACHEDEV2_DATA/Medias/MyTube/uploads:/app/uploads
- /share/CACHEDEV2_DATA/Medias/MyTube/data:/app/data
@@ -25,8 +23,8 @@ services:
environment:
# For internal container communication, use the service name
# These will be replaced at runtime by the entrypoint script
- VITE_API_URL=http://backend:5551/api
- VITE_BACKEND_URL=http://backend:5551
- VITE_API_URL=/api
- VITE_BACKEND_URL=
# For QNAP or other environments where service discovery doesn't work,
# you can override these values using a .env file with:
# - API_HOST=your-ip-or-hostname

View File

@@ -6,8 +6,8 @@ DEFAULT_API_URL="http://localhost:5551/api"
DEFAULT_BACKEND_URL="http://localhost:5551"
# Runtime values from docker-compose environment variables
DOCKER_API_URL="${VITE_API_URL:-http://backend:5551/api}"
DOCKER_BACKEND_URL="${VITE_BACKEND_URL:-http://backend:5551}"
DOCKER_API_URL="${VITE_API_URL-http://backend:5551/api}"
DOCKER_BACKEND_URL="${VITE_BACKEND_URL-http://backend:5551}"
# If API_HOST is provided, override with custom host configuration
if [ ! -z "$API_HOST" ]; then

View File

@@ -6,6 +6,30 @@ server {
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://backend:5551/api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ^~ /videos {
proxy_pass http://backend:5551/videos;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ^~ /images {
proxy_pass http://backend:5551/images;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Cache static assets
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {