diff --git a/check-env.sh b/check-env.sh new file mode 100644 index 00000000..2978974b --- /dev/null +++ b/check-env.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +cd /home/ubuntu/vf_react/src/views/AgentChat/neuratalk + +echo "=========================================" +echo "检查并修复环境配置" +echo "=========================================" + +# 1. 创建正确的 .env.local +echo "创建 .env.local 文件..." +cat > .env.local << 'EOF' +# API 配置 - 重要!必须设置 +NEXT_PUBLIC_API_URL=http://49.232.185.254:5001 +NEXT_PUBLIC_MAIN_APP_URL=https://valuefrontier.cn + +# Session 配置 +SESSION_COOKIE_NAME=session +PORT=3000 +EOF + +echo "✓ 环境文件已创建" +echo "" +echo "内容:" +cat .env.local +echo "" + +# 2. 检查文件是否存在 +if [ -f ".env.local" ]; then + echo "✓ .env.local 文件存在" +else + echo "✗ .env.local 文件不存在" +fi + +echo "" +echo "请重启 Next.js 服务器(Ctrl+C 然后 npm run dev)" \ No newline at end of file diff --git a/check-nginx.sh b/check-nginx.sh new file mode 100644 index 00000000..e567780b --- /dev/null +++ b/check-nginx.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +echo "=========================================" +echo "检查 Nginx 配置" +echo "=========================================" + +# 1. 检查配置文件是否包含 ai-chat 配置 +echo "检查 /ai-chat 配置..." +if grep -q "location /ai-chat" /etc/nginx/sites-available/valuefrontier; then + echo "✓ 找到 /ai-chat 配置" + grep -A 10 "location /ai-chat" /etc/nginx/sites-available/valuefrontier +else + echo "✗ 未找到 /ai-chat 配置" + echo "" + echo "请添加以下配置到 /etc/nginx/sites-available/valuefrontier:" + echo "(在 location /chat/ 之前添加)" + echo "" + cat << 'EOF' + # AI Chat 应用 (Next.js) + location /ai-chat { + rewrite ^/ai-chat(.*)$ $1 break; + proxy_pass http://127.0.0.1:3000; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Cookie $http_cookie; + proxy_pass_request_headers on; + proxy_buffering off; + } +EOF +fi + +echo "" +echo "测试 Nginx 配置:" +sudo nginx -t + +echo "" +echo "如果需要编辑:" +echo "sudo nano /etc/nginx/sites-available/valuefrontier" +echo "" +echo "编辑后重载:" +echo "sudo nginx -s reload" \ No newline at end of file diff --git a/quick-fix.sh b/quick-fix.sh new file mode 100644 index 00000000..44d023b3 --- /dev/null +++ b/quick-fix.sh @@ -0,0 +1,85 @@ +#!/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 "=========================================" \ No newline at end of file diff --git a/src/views/AgentChat/neuratalk/components/Chat/MCPChat.tsx b/src/views/AgentChat/neuratalk/components/Chat/MCPChat.tsx index 63567c7f..952f882a 100644 --- a/src/views/AgentChat/neuratalk/components/Chat/MCPChat.tsx +++ b/src/views/AgentChat/neuratalk/components/Chat/MCPChat.tsx @@ -138,11 +138,12 @@ export default function MCPChat() { } if (!isAuthenticated) { + const mainAppUrl = process.env.NEXT_PUBLIC_MAIN_APP_URL || 'https://valuefrontier.cn'; return (