#!/bin/bash echo "=========================================" echo "快速修复 AgentChat 配置" echo "=========================================" cd /home/ubuntu/vf_react/src/views/AgentChat/neuratalk # 1. 停止当前进程 echo "停止现有进程..." pkill -f "next dev" 2>/dev/null # 2. 创建环境文件 echo "创建环境配置..." cat > .env.local << 'EOF' NEXT_PUBLIC_API_URL=http://49.232.185.254:5001 NEXT_PUBLIC_MAIN_APP_URL=https://valuefrontier.cn SESSION_COOKIE_NAME=session PORT=3000 EOF # 3. 修复 Next.js 配置 echo "修复 Next.js 配置..." cat > next.config.js << 'EOF' /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, poweredByHeader: false, outputFileTracingRoot: '/home/ubuntu/vf_react/src/views/AgentChat/neuratalk', // 允许跨域开发 async headers() { return [ { source: '/:path*', headers: [ { key: 'Access-Control-Allow-Credentials', value: 'true', }, { key: 'Access-Control-Allow-Origin', value: '*', }, ], }, ]; }, // API 代理 async rewrites() { return [ { source: '/api/:path*', destination: 'http://localhost:5001/api/:path*', }, { source: '/mcp/:path*', destination: 'http://localhost:8900/:path*', }, ]; }, images: { domains: ['valuefrontier.cn', 'localhost', '49.232.185.254'], }, }; module.exports = nextConfig; EOF # 4. 删除 TypeScript 配置(如果存在) rm -f next.config.ts echo "" echo "✓ 配置修复完成" echo "" echo "现在请运行:" echo "npm run dev" echo "" echo "然后访问:" echo "- 直接访问: http://49.232.185.254:3000" echo "- 通过 Nginx: https://valuefrontier.cn/ai-chat" echo "" echo "========================================="