diff --git a/app/about/cn/page.tsx b/app/about/cn/page.tsx
index 6c74ae61..d0a2f408 100644
--- a/app/about/cn/page.tsx
+++ b/app/about/cn/page.tsx
@@ -2,6 +2,7 @@ import type { Metadata } from "next"
import Image from "next/image"
import Link from "next/link"
import { FaGithub } from "react-icons/fa"
+import nextConfig from "@/next.config"
export const metadata: Metadata = {
title: "关于 - Next AI Draw.io",
@@ -270,7 +271,7 @@ export default function AboutCN() {
动画连接器的Transformer架构图。
({ ...prev, [messageId]: value }))
try {
- await fetch("/api/log-feedback", {
+ await fetch(`${nextConfig.basePath}/api/log-feedback`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx
index b7408b0b..d2966635 100644
--- a/components/chat-panel.tsx
+++ b/components/chat-panel.tsx
@@ -27,6 +27,7 @@ import { isPdfFile, isTextFile } from "@/lib/pdf-utils"
import { type FileData, useFileProcessor } from "@/lib/use-file-processor"
import { useQuotaManager } from "@/lib/use-quota-manager"
import { formatXML, isMxCellXmlComplete, wrapWithMxFile } from "@/lib/utils"
+import nextConfig from "@/next.config"
import { ChatMessageDisplay } from "./chat-message-display"
// localStorage keys for persistence
@@ -150,7 +151,7 @@ export default function ChatPanel({
// Check config on mount
useEffect(() => {
- fetch("/api/config")
+ fetch(`${nextConfig.basePath}/api/config`)
.then((res) => res.json())
.then((data) => {
setAccessCodeRequired(data.accessCodeRequired)
@@ -225,7 +226,7 @@ export default function ChatPanel({
setMessages,
} = useChat({
transport: new DefaultChatTransport({
- api: "/api/chat",
+ api: `${nextConfig.basePath}/api/chat`,
}),
async onToolCall({ toolCall }) {
if (DEBUG) {
diff --git a/components/settings-dialog.tsx b/components/settings-dialog.tsx
index 30381f59..d97c85e7 100644
--- a/components/settings-dialog.tsx
+++ b/components/settings-dialog.tsx
@@ -20,6 +20,7 @@ import {
SelectValue,
} from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
+import nextConfig from "@/next.config"
interface SettingsDialogProps {
open: boolean
@@ -71,7 +72,7 @@ export function SettingsDialog({
// Only fetch if not cached in localStorage
if (getStoredAccessCodeRequired() !== null) return
- fetch("/api/config")
+ fetch(`${nextConfig.basePath}/api/config`)
.then((res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`)
return res.json()
@@ -119,12 +120,15 @@ export function SettingsDialog({
setIsVerifying(true)
try {
- const response = await fetch("/api/verify-access-code", {
- method: "POST",
- headers: {
- "x-access-code": accessCode.trim(),
+ const response = await fetch(
+ `${nextConfig.basePath}/api/verify-access-code`,
+ {
+ method: "POST",
+ headers: {
+ "x-access-code": accessCode.trim(),
+ },
},
- })
+ )
const data = await response.json()
diff --git a/contexts/diagram-context.tsx b/contexts/diagram-context.tsx
index a7cd4abd..7381cc11 100644
--- a/contexts/diagram-context.tsx
+++ b/contexts/diagram-context.tsx
@@ -5,6 +5,7 @@ import { createContext, useContext, useRef, useState } from "react"
import type { DrawIoEmbedRef } from "react-drawio"
import { STORAGE_DIAGRAM_XML_KEY } from "@/components/chat-panel"
import type { ExportFormat } from "@/components/save-dialog"
+import nextConfig from "@/next.config"
import { extractDiagramXML, validateAndFixXml } from "../lib/utils"
interface DiagramContextType {
@@ -284,7 +285,7 @@ export function DiagramProvider({ children }: { children: React.ReactNode }) {
sessionId?: string,
) => {
try {
- await fetch("/api/log-save", {
+ await fetch(`${nextConfig.basePath}/api/log-save`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ filename, format, sessionId }),
diff --git a/docker-compose.yml b/docker-compose.yml
index 84970bca..115b098d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -8,5 +8,7 @@ services:
args:
- NEXT_PUBLIC_DRAWIO_BASE_URL=http://localhost:8080
ports: ["3000:3000"]
+ environment:
+ - NEXT_PUBLIC_BASE_PATH=/nextaidrawio
env_file: .env
- depends_on: [drawio]
+ depends_on: [drawio]
\ No newline at end of file
diff --git a/next.config.ts b/next.config.ts
index 8c0356a6..9db90227 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -3,6 +3,7 @@ import type { NextConfig } from "next"
const nextConfig: NextConfig = {
/* config options here */
output: "standalone",
+ basePath: process.env.NEXT_PUBLIC_BASE_PATH || "",
}
export default nextConfig