修正:Dify统一使用FastAPI后端地址,移除独立difyBaseUrl配置
问题:错误地为Dify创建了独立的difyBaseUrl配置
正确架构:
客户端 → /api/* → Remix routes → dify-client.server →
FastAPI baseUrl/dify/* → Dify服务
修改:
1. app/config/api-config.ts
- 移除 difyBaseUrl 字段
- 所有环境统一使用 baseUrl (FastAPI后端地址)
- 添加注释说明 baseUrl 包含 /dify 代理
2. app/services/dify-client.server.ts
- 使用 API_BASE_URL 而非 DIFY_BASE_URL
- API_URL: `${API_BASE_URL}/dify`
各环境FastAPI地址:
- development: http://172.16.0.55:8000
- testing: http://nas.7bm.co:8873
- production: http://10.79.97.17:8000
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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<string, Partial<ApiConfig>> = {
|
||||
const configs: Record<string, ApiConfig> = {
|
||||
// 开发环境
|
||||
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<string, ApiConfig> = {
|
||||
|
||||
// 测试环境
|
||||
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<string, ApiConfig> = {
|
||||
|
||||
// 生产环境
|
||||
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<string, ApiConfig> = {
|
||||
|
||||
// 备用配置 (可以根据需要添加更多环境)
|
||||
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
|
||||
|
||||
@@ -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: (() => {
|
||||
|
||||
Reference in New Issue
Block a user