Commit 8472f7f4 by luoqi

fix:update

parent f5609a93
Pipeline #3218 failed with stage
in 2 minutes 8 seconds
# 前端环境变量配置
# API 服务地址 - 指向外部API服务
VITE_API_BASE_URL=https://tools-performance-score.jarvismedical.asia
VITE_API_BASE_URL=http://localhost:8000
# 应用配置
VITE_APP_TITLE=绩效计分系统
......
......@@ -12,7 +12,7 @@ RUN npm ci --silent || npm install --legacy-peer-deps
COPY . .
# 设置构建时环境变量
ARG VITE_API_BASE_URL=https://tools-performance-score.jarvismedical.asia
ARG VITE_API_BASE_URL
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
# 构建应用
......
......@@ -56,7 +56,7 @@ services:
context: .
dockerfile: Dockerfile
args:
VITE_API_BASE_URL: ${VITE_API_BASE_URL:-https://tools-performance-score.jarvismedical.asia}
VITE_API_BASE_URL: ${VITE_API_BASE_URL}
container_name: performance_frontend
ports:
- "4001:80"
......
......@@ -7,6 +7,28 @@ server {
root /usr/share/nginx/html;
index index.html;
# API 代理到后端服务(仅当使用相对路径 /api 时)
location /api/ {
proxy_pass http://api:8000/;
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;
# CORS 头部
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type, Authorization";
# 处理 OPTIONS 预检请求
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type, Authorization";
return 204;
}
}
# 处理前端路由:不存在的路径回退 index.html
location / {
try_files $uri $uri/ /index.html;
......
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