/** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, output: 'standalone', async rewrites() { // NEXT_PUBLIC_API_URL 应该是后端服务的基础 URL,如 http://mining-admin-service:3023 // 前端请求 /api/xxx 会被转发到 {API_URL}/api/v2/xxx const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3023'; // 移除末尾可能存在的 /api/v2 避免重复 const cleanUrl = apiBaseUrl.replace(/\/api\/v2\/?$/, ''); return [ { source: '/api/:path*', destination: `${cleanUrl}/api/v2/:path*`, }, ]; }, }; module.exports = nextConfig;