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:
commit
038d14d2f8
@ -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 }),
|
||||
})
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user