This commit is contained in:
2026-02-02 00:55:56 +08:00
parent 8f087d690c
commit f93cec6f0b
2 changed files with 4 additions and 3 deletions

View File

@@ -4,7 +4,7 @@
* Validates: Requirements 12.1-12.6 * Validates: Requirements 12.1-12.6
*/ */
import api from './api'; import api, { API_BASE_URL } from './api';
import type { import type {
ApiResponse, ApiResponse,
AIChatResponse, AIChatResponse,
@@ -108,7 +108,7 @@ export async function streamChatMessage(
const token = localStorage.getItem('token'); // Assuming auth token is stored here const token = localStorage.getItem('token'); // Assuming auth token is stored here
// Use fetch directly for streaming support // 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', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@@ -7,7 +7,8 @@
// 优先使用环境变量配置 // 优先使用环境变量配置
// 开发环境 (.env.development): http://localhost:2612/api/v1 // 开发环境 (.env.development): http://localhost:2612/api/v1
// 生产环境 (.env.production): /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') ((window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')
? 'http://localhost:2612/api/v1' ? 'http://localhost:2612/api/v1'
: '/api/v1'); : '/api/v1');