feat: 适配 Nginx /ai/ 路径前缀
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 1m25s

This commit is contained in:
2026-04-14 02:37:42 +08:00
parent 58b424982a
commit 8eccec3fb8
3 changed files with 4 additions and 4 deletions

View File

@@ -12,4 +12,4 @@ ENV PYTHONPATH=/app
EXPOSE 8501 EXPOSE 8501
CMD ["streamlit", "run", "frontend/frontend.py", "--server.port", "8501", "--server.address", "0.0.0.0"] CMD ["streamlit", "run", "frontend/frontend.py", "--server.port", "8501", "--server.address", "0.0.0.0", "--server.baseUrlPath", "/ai"]

View File

@@ -46,7 +46,7 @@ services:
dockerfile: docker/Dockerfile.frontend dockerfile: docker/Dockerfile.frontend
container_name: ai-frontend container_name: ai-frontend
environment: environment:
- API_URL=/api/chat # 通过 Nginx 反向代理访问后端 - API_URL=/ai/api/chat # 通过 Nginx 反向代理访问后端(路径前缀 /ai
ports: ports:
- "127.0.0.1:8501:8501" # 仅本机访问,供 Nginx 反向代理使用 - "127.0.0.1:8501:8501" # 仅本机访问,供 Nginx 反向代理使用
networks: networks:

View File

@@ -13,8 +13,8 @@ import streamlit as st
# 原来的硬编码,本地测试 # 原来的硬编码,本地测试
# API_URL = "http://115.190.121.151:8001/chat" # API_URL = "http://115.190.121.151:8001/chat"
# 改为相对路径(由 Nginx 代理转发) # 改为相对路径(由 Nginx 代理转发,路径前缀为 /ai
API_URL = "/api/chat" API_URL = "/ai/api/chat"
st.set_page_config(page_title="AI 个人助手", page_icon="🤖") st.set_page_config(page_title="AI 个人助手", page_icon="🤖")
st.title("🤖 个人生活与数据分析助手") st.title("🤖 个人生活与数据分析助手")