Update API and WebSocket base URLs to use environment variables for better configuration management
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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);
|
||||
|
||||
// 禁用调试日志
|
||||
|
||||
Reference in New Issue
Block a user