From f93cec6f0b5b4c0b2a0c9e4bdffab48c0e202383 Mon Sep 17 00:00:00 2001 From: 12975 <1297598740@qq.com> Date: Mon, 2 Feb 2026 00:55:56 +0800 Subject: [PATCH] 986 --- src/services/aiService.ts | 4 ++-- src/services/api.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/services/aiService.ts b/src/services/aiService.ts index 8c4ab8a..08baf89 100644 --- a/src/services/aiService.ts +++ b/src/services/aiService.ts @@ -4,7 +4,7 @@ * Validates: Requirements 12.1-12.6 */ -import api from './api'; +import api, { API_BASE_URL } from './api'; import type { ApiResponse, AIChatResponse, @@ -108,7 +108,7 @@ export async function streamChatMessage( const token = localStorage.getItem('token'); // Assuming auth token is stored here // Use fetch directly for streaming support - const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/ai/chat/stream`, { + const response = await fetch(`${API_BASE_URL}/ai/chat/stream`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/services/api.ts b/src/services/api.ts index 3a42bd9..06e7926 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -7,7 +7,8 @@ // 优先使用环境变量配置 // 开发环境 (.env.development): http://localhost:2612/api/v1 // 生产环境 (.env.production): /api/v1 -const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || +// 生产环境 (.env.production): /api/v1 +export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || ((window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') ? 'http://localhost:2612/api/v1' : '/api/v1');