update pay function

This commit is contained in:
2025-11-22 09:16:12 +08:00
parent 7498e87d31
commit 092c86f3d2
5 changed files with 171 additions and 2 deletions

35
check-env.sh Normal file
View File

@@ -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"

44
check-nginx.sh Normal file
View File

@@ -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"

85
quick-fix.sh Normal file
View File

@@ -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 "========================================="

View File

@@ -138,11 +138,12 @@ export default function MCPChat() {
}
if (!isAuthenticated) {
const mainAppUrl = process.env.NEXT_PUBLIC_MAIN_APP_URL || 'https://valuefrontier.cn';
return (
<div className="flex flex-col items-center justify-center h-screen">
<h2 className="text-2xl mb-4"></h2>
<a
href={`${process.env.NEXT_PUBLIC_MAIN_APP_URL}/auth/sign-in?redirect=/chat`}
href={`${mainAppUrl}/auth/sign-in?redirect=/ai-chat`}
className="bg-blue-600 text-white px-6 py-2 rounded hover:bg-blue-700"
>

View File

@@ -22,8 +22,12 @@ export interface AuthInfo {
*/
export async function checkAuth(): Promise<AuthInfo> {
try {
// 使用硬编码的 URL 作为后备
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://49.232.185.254:5001';
console.log('API URL:', apiUrl); // 调试日志
// 调用主应用的 session 检查接口
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/auth/session`, {
const response = await fetch(`${apiUrl}/api/auth/session`, {
credentials: 'include', // 重要:携带 Cookie
headers: {
'Content-Type': 'application/json',