fix: use dynamic URLs for API and Socket.IO

- Change API_URL from hardcoded 'http://localhost:8080/api' to '/api'
- Change SOCKET_URL from hardcoded to window.location.origin
- Fixes production build connecting to wrong port
- Now works correctly in both dev (localhost:8080) and prod (localhost)
This commit is contained in:
Radosław Gierwiało
2025-11-15 18:03:40 +01:00
parent e27da81346
commit f5938f1a1e
2 changed files with 6 additions and 2 deletions

View File

@@ -1,4 +1,6 @@
const API_URL = 'http://localhost:8080/api';
// Use relative URL - works for both dev (localhost:8080) and prod (localhost)
// Nginx proxies /api to backend
const API_URL = '/api';
class ApiError extends Error {
constructor(message, status, data) {

View File

@@ -1,6 +1,8 @@
import { io } from 'socket.io-client';
const SOCKET_URL = 'http://localhost:8080';
// Use current origin - works for both dev (localhost:8080) and prod (localhost)
// Nginx proxies /socket.io to backend
const SOCKET_URL = window.location.origin;
let socket = null;