Files
deepdata/deepflow/web/next.config.js
T
apescale 98b52fdb31
CodeQL Advanced / Analyze (actions) (push) Canceled after 0s
CodeQL Advanced / Analyze (java-kotlin) (push) Canceled after 0s
CodeQL Advanced / Analyze (javascript-typescript) (push) Canceled after 0s
CodeQL Advanced / Analyze (python) (push) Canceled after 0s
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
2026-08-31 06:23:31 +08:00

60 lines
1.9 KiB
JavaScript

/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT
import "./src/env.js";
import createNextIntlPlugin from 'next-intl/plugin';
const withNextIntl = createNextIntlPlugin('./src/i18n.ts');
/** @type {import("next").NextConfig} */
// DeepFlow leverages **Turbopack** during development for faster builds and a smoother developer experience.
// However, in production, **Webpack** is used instead.
//
// This decision is based on the current recommendation to avoid using Turbopack for critical projects, as it
// is still evolving and may not yet be fully stable for production environments.
const config = {
// For development mode
turbopack: {
rules: {
"*.md": {
loaders: ["raw-loader"],
as: "*.js",
},
},
},
// For production mode
webpack: (config) => {
config.module.rules.push({
test: /\.md$/,
use: "raw-loader",
});
return 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);