diff --git a/app/config/api-config.ts b/app/config/api-config.ts index 40fc57b..c5fd686 100644 --- a/app/config/api-config.ts +++ b/app/config/api-config.ts @@ -5,10 +5,8 @@ */ // 环境配置类型 interface ApiConfig { - // 主API基础URL + // 主API基础URL(FastAPI后端地址,包含Dify代理) baseUrl: string; - // Dify对话服务URL(独立配置,使用外网地址) - difyBaseUrl: string; // 文档服务URL documentUrl: string; // 文档上传API URL @@ -124,8 +122,7 @@ const portConfigs: Record> = { const configs: Record = { // 开发环境 development: { - baseUrl: 'http://172.16.0.55:8000', - difyBaseUrl: 'http://nas.7bm.co:8000', // Dify对话服务使用外网地址 + baseUrl: 'http://172.16.0.55:8000', // FastAPI后端(包含/dify代理) documentUrl: 'http://172.16.0.55:8000/docauditai/', uploadUrl: 'http://172.16.0.55:8000/admin/documents', oauth: { @@ -139,8 +136,7 @@ const configs: Record = { // 测试环境 testing: { - baseUrl: 'http://nas.7bm.co:8873', - difyBaseUrl: 'http://nas.7bm.co:8000', // Dify对话服务使用外网地址 + baseUrl: 'http://nas.7bm.co:8873', // FastAPI后端(包含/dify代理) documentUrl: 'http://nas.7bm.co:8873/docauditai/', uploadUrl: 'http://nas.7bm.co:8873/admin/documents', oauth: { @@ -154,10 +150,7 @@ const configs: Record = { // 生产环境 production: { - // postgrest - baseUrl: 'http://10.79.97.17:8000', - // Dify对话服务使用外网地址 - difyBaseUrl: 'http://nas.7bm.co:8000', + baseUrl: 'http://10.79.97.17:8000', // FastAPI后端(包含/dify代理) // minio documentUrl: 'http://10.76.244.156:9000/docauditai/', // 文件上传 @@ -176,8 +169,7 @@ const configs: Record = { // 备用配置 (可以根据需要添加更多环境) staging: { - baseUrl: 'http://172.16.0.119:9000/admin', - difyBaseUrl: 'http://nas.7bm.co:8000', // Dify对话服务使用外网地址 + baseUrl: 'http://172.16.0.119:9000/admin', // FastAPI后端(包含/dify代理) documentUrl: 'http://nas.7bm.co:9000/docauditai/', uploadUrl: 'http://172.16.0.119:8000/admin/documents/upload', oauth: { @@ -351,7 +343,6 @@ export const apiConfig = getCurrentConfig(); // 导出具体的配置项,方便使用 export const { baseUrl: API_BASE_URL, - difyBaseUrl: DIFY_BASE_URL, documentUrl: DOCUMENT_URL, uploadUrl: UPLOAD_URL, oauth: OAUTH_CONFIG diff --git a/app/services/dify-client.server.ts b/app/services/dify-client.server.ts index 19f1c2d..052b8ad 100644 --- a/app/services/dify-client.server.ts +++ b/app/services/dify-client.server.ts @@ -1,4 +1,4 @@ -import { DIFY_BASE_URL } from '~/config/api-config'; +import { API_BASE_URL } from '~/config/api-config'; // 获取环境变量的服务端函数 const getServerEnvVar = (name: string, defaultValue: string = '') => { @@ -14,8 +14,9 @@ const getServerEnvVar = (name: string, defaultValue: string = '') => { // Dify API 客户端配置 // 注意:现在通过 FastAPI 后端的 /dify 路由代理访问 Dify,使用 JWT 认证 const DIFY_CONFIG = { - // API_URL 指向 FastAPI 后端的 /dify 路由(使用外网地址 nas.7bm.co:8000) - API_URL: `${DIFY_BASE_URL}/dify`, + // API_URL 指向 FastAPI 后端的 /dify 路由 + // API_BASE_URL 来自 api-config.ts,根据环境/端口自动配置 + API_URL: `${API_BASE_URL}/dify`, // API_KEY 保留用于配置验证(实际不再使用,改用JWT) API_KEY: getServerEnvVar('NEXT_PUBLIC_APP_KEY', ''), APP_ID: (() => {