Commit f5609a93 by luoqi

fix:update

parent 4e323670
Pipeline #3217 failed with stage
in 2 minutes 8 seconds
# 前端环境变量配置
# API 服务地址 - 直接指向后端服务
VITE_API_BASE_URL=http://localhost:8000
# API 服务地址 - 指向外部API服务
VITE_API_BASE_URL=https://tools-performance-score.jarvismedical.asia
# 应用配置
VITE_APP_TITLE=绩效计分系统
......
......@@ -12,7 +12,7 @@ RUN npm ci --silent || npm install --legacy-peer-deps
COPY . .
# 设置构建时环境变量
ARG VITE_API_BASE_URL=http://localhost:8000
ARG VITE_API_BASE_URL=https://tools-performance-score.jarvismedical.asia
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
# 构建应用
......
......@@ -37,9 +37,7 @@ class Settings(BaseSettings):
MAX_IMAGES_PER_INSTITUTION: int = 10
# CORS 配置
CORS_ORIGINS: List[str] = [
"*", # 开发环境允许所有来源
]
CORS_ORIGINS: str = "*" # 简化为字符串格式,避免 JSON 解析问题
# WebSocket 配置
WEBSOCKET_HEARTBEAT_INTERVAL: int = 30
......
......@@ -92,9 +92,17 @@ app = FastAPI(
)
# 配置 CORS 中间件
# 处理 CORS_ORIGINS 配置,支持字符串和列表格式
cors_origins = settings.CORS_ORIGINS
if isinstance(cors_origins, str):
if cors_origins == "*":
cors_origins = ["*"]
else:
cors_origins = [cors_origins]
app.add_middleware(
CORSMiddleware,
allow_origins=settings.CORS_ORIGINS,
allow_origins=cors_origins,
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allow_headers=["*"],
......
......@@ -56,7 +56,7 @@ services:
context: .
dockerfile: Dockerfile
args:
- VITE_API_BASE_URL=http://localhost:8000
VITE_API_BASE_URL: ${VITE_API_BASE_URL:-https://tools-performance-score.jarvismedical.asia}
container_name: performance_frontend
ports:
- "4001:80"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment