修正端口到3001

This commit is contained in:
2025-09-18 23:53:15 +08:00
parent a8a7947942
commit 139245792f
5 changed files with 58 additions and 4 deletions

View File

@@ -37,7 +37,7 @@ export interface Student {
class DatabaseService {
private static instance: DatabaseService;
private baseUrl: string = 'http://localhost:3001/api';
private baseUrl: string = 'http://localhost:3010/api';
private constructor() {
// 直接使用服务器API无需初始化本地数据库

View File

@@ -30,10 +30,10 @@ class WebSocketService {
// 获取当前主机地址和端口配置
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const host = window.location.hostname === 'localhost' ? 'localhost' : window.location.hostname;
const port = process.env.NODE_ENV === 'production' ? window.location.port || '80' : '3001';
const port = process.env.NODE_ENV === 'production' ? window.location.port || '80' : '3010';
const socketUrl = process.env.NODE_ENV === 'production'
? `${protocol}//${host}${port !== '80' && port !== '443' ? ':' + port : ''}`
: `${protocol}//${host}:3001`;
: `${protocol}//${host}:3010`;
console.log('🔌 连接WebSocket服务器:', socketUrl, '(环境:', process.env.NODE_ENV, ')');