37 lines
734 B
TypeScript
37 lines
734 B
TypeScript
import type { NextConfig } from 'next';
|
|
|
|
const isProd = process.env.NODE_ENV === 'production';
|
|
|
|
const nextConfig: NextConfig = {
|
|
// 生产环境静态导出,开发环境正常运行
|
|
...(isProd ? { output: 'export' } : {}),
|
|
|
|
// 图片优化(静态导出时禁用)
|
|
images: {
|
|
unoptimized: true,
|
|
},
|
|
|
|
// 尾随斜杠
|
|
trailingSlash: false,
|
|
|
|
// 开发环境 API 代理
|
|
async rewrites() {
|
|
if (!isProd) {
|
|
return [
|
|
{
|
|
source: '/api/:path*',
|
|
destination: 'http://localhost:8000/api/:path*',
|
|
},
|
|
{
|
|
source: '/health',
|
|
destination: 'http://localhost:8000/health',
|
|
},
|
|
];
|
|
}
|
|
return [];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|
|
|