Merge pull request #55 from svc-design/codex/fix-hardcoded-port-in-askaidialog

feat(ui): proxy API calls and allow configurable endpoint
This commit is contained in:
shenlan 2025-08-03 08:28:32 +08:00 committed by GitHub
commit 038d14d2f8
2 changed files with 12 additions and 6 deletions

View File

@ -11,7 +11,8 @@ export function AskAIDialog({ open, onClose }: { open: boolean; onClose: () => v
async function handleAsk() {
if (!question) return
const userMessage = { sender: 'user' as const, text: question }
const res = await fetch('/api/askai', {
const apiBase = process.env.NEXT_PUBLIC_API_BASE_URL || ''
const res = await fetch(`${apiBase}/api/askai`, {
method: 'POST',
body: JSON.stringify({ question, history: messages }),
})

View File

@ -1,11 +1,16 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export', // 开启静态导出
output: 'export', // 静态导出
reactStrictMode: true,
// 移除 experimental.appDir
// experimental: {
// appDir: true
// }
async rewrites() {
return [
{
source: '/api/:path*',
destination: 'http://localhost:3002/api/:path*', // 后端服务
},
]
},
}
module.exports = nextConfig