rwadurian/frontend/mining-admin-web/next.config.js

21 lines
656 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** @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;