fix(deploy): proxy /deepflow-backend/* to backend /api/* in Docker + expose deepflow ports
- next.config.js: server-side rewrites so the standalone frontend (built with NEXT_PUBLIC_API_URL=/deepflow-backend) can reach deepflow-backend:8000/api/* without CORS; target overridable via DEEPFLOW_BACKEND_HOST - docker-compose: expose deepflow-frontend 3001:3000 and deepflow-backend 8000:8000
This commit is contained in:
@@ -40,6 +40,20 @@ const config = {
|
||||
|
||||
// ... rest of the configuration.
|
||||
output: "standalone",
|
||||
|
||||
// Docker standalone 部署:把 /deepflow-backend/* 代理到 deepflow-backend 服务。
|
||||
// 前端以 NEXT_PUBLIC_API_URL=/deepflow-backend 构建(见
|
||||
// src/core/api/resolve-service-url.ts,直接拼 origin + /deepflow-backend/<path>),
|
||||
// 而后端路由均带 /api 前缀(见 src/server/app.py)。由 Next 服务端补上 /api 前缀,
|
||||
// 避免浏览器跨端口 / CORS 问题。目标地址可用 DEEPFLOW_BACKEND_HOST 覆盖。
|
||||
async rewrites() {
|
||||
const backendHost =
|
||||
process.env.DEEPFLOW_BACKEND_HOST || "http://deepflow-backend:8000";
|
||||
return [
|
||||
{ source: "/deepflow-backend/:path*", destination: `${backendHost}/api/:path*` },
|
||||
{ source: "/deepflow-backend", destination: `${backendHost}/api/` },
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
export default withNextIntl(config);
|
||||
|
||||
@@ -205,6 +205,8 @@ services:
|
||||
container_name: deepflow-backend
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- ./conf.yaml:/app/conf.yaml:ro
|
||||
- deepflow-log-volume:/var/log/deepflow
|
||||
@@ -219,6 +221,8 @@ services:
|
||||
container_name: deepflow-frontend
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "3001:3000"
|
||||
depends_on:
|
||||
- deepflow-backend
|
||||
restart: on-failure
|
||||
|
||||
Reference in New Issue
Block a user