fix: Remove hardcoded ports, support custom port configuration

- Replace all hardcoded localhost:8000/3000/8501 with environment variables
- Frontend: Use API_PORT env var in next.config.ts
- Backend: Use API_PORT env var in editor.py and quality.py
- Web UI: Use API_PORT and EDITOR_PORT env vars in all Streamlit pages
- Update dev.sh to pass environment variables to all services
- Add .env.example with port configuration template

Now supports custom ports via environment variables:
  API_PORT=8080 EDITOR_PORT=3001 WEB_PORT=8502 ./dev.sh

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2026-01-10 16:13:02 +08:00
parent 6bf16936af
commit 3f59b324ad
8 changed files with 61 additions and 18 deletions

View File

@@ -22,6 +22,7 @@ Features:
import streamlit as st
import requests
import time
import os
from datetime import datetime
from web.i18n import tr, get_language
@@ -33,8 +34,12 @@ st.set_page_config(
layout="wide",
)
# Get ports from environment
API_PORT = os.getenv("API_PORT", "8000")
EDITOR_PORT = os.getenv("EDITOR_PORT", "3000")
# API endpoint
API_BASE = "http://localhost:8000/api"
API_BASE = f"http://localhost:{API_PORT}/api"
def get_all_tasks():
@@ -183,7 +188,7 @@ def render_task_card(task):
with col_a:
st.success("✨ 视频生成成功")
with col_b:
editor_url = f"http://localhost:3000/editor?storyboard_id={task_id}"
editor_url = f"http://localhost:{EDITOR_PORT}/editor?storyboard_id={task_id}"
st.markdown(
f'''
<a href="{editor_url}" target="_blank" style="text-decoration: none;">