Update API and WebSocket base URLs to use environment variables for better configuration management

This commit is contained in:
liu
2026-01-30 00:45:04 +08:00
parent 197ce5e7ea
commit 246515b43e
11 changed files with 310 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ import axios from 'axios';
import { ElMessage } from 'element-plus';
const request = axios.create({
baseURL: 'http://localhost:8080',
baseURL: import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8080',
timeout: 30000,
headers: {
'Content-Type': 'application/json'

View File

@@ -30,7 +30,11 @@ export function useWebSocket(taskId: string | null, onMessage: (msg: ProgressMes
}
try {
const socket = new SockJS('http://localhost:8080/ws');
const wsBase =
import.meta.env.VITE_WS_BASE_URL !== undefined && import.meta.env.VITE_WS_BASE_URL !== ''
? import.meta.env.VITE_WS_BASE_URL
: (typeof window !== 'undefined' ? window.location.origin : 'http://localhost:8080');
const socket = new SockJS(`${wsBase}/ws`);
stompClient = Stomp.over(socket);
// 禁用调试日志