// const BASE_URL = 'https://77.smartvideo.py.qikongjian.com' // const BASE_URL = 'http://192.168.120.36:8000' /** @type {import('next').NextConfig} */ const nextConfig = { eslint: { ignoreDuringBuilds: true, }, images: { unoptimized: true }, webpack: (config, { dev, isServer }) => { if (dev && !isServer) { // 开发环境优化 config.optimization.splitChunks = { chunks: 'all', cacheGroups: { vendor: { test: /[\\/]node_modules[\\/]/, name: 'vendors', chunks: 'all', priority: 20, }, default: { chunks: 'async', minChunks: 2, priority: 10, reuseExistingChunk: true, }, }, }; } // 优化缓存配置,解决缓存错误问题 if (dev) { config.cache = { type: 'memory', // 设置内存缓存大小限制(512MB) maxGenerations: 1, }; } return config; }, async rewrites() { // 使用环境变量,如果没有则使用默认值 const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL // 用户认证后端API const AUTH_API_URL = process.env.NEXT_PUBLIC_JAVA_URL // const BASE_URL = 'http://192.168.120.5:8000' return [ // Google OAuth2 API代理 (排除callback,让Next.js本地处理) { source: '/api/auth/google/((?!callback).*)', destination: `${AUTH_API_URL}/api/auth/google/$1`, }, // 其他认证相关API代理 (排除google路径) { source: '/api/auth/((?!google).)*', destination: `${AUTH_API_URL}/api/auth/$1`, }, { source: '/api/user/:path*', destination: `${AUTH_API_URL}/api/user/:path*`, }, { source: '/api/proxy/:path*', destination: `${BASE_URL}/:path*`, }, { source: '/api/resources/:path*', destination: `${BASE_URL}/:path*`, }, ]; }, // 设置生成超时时间 staticPageGenerationTimeout: 120, }; module.exports = nextConfig;