From f5938f1a1e838dfa2b4cd4d02089e8a543552f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Gierwia=C5=82o?= Date: Sat, 15 Nov 2025 18:03:40 +0100 Subject: [PATCH] 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) --- frontend/src/services/api.js | 4 +++- frontend/src/services/socket.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js index f2357cf..4a18f29 100644 --- a/frontend/src/services/api.js +++ b/frontend/src/services/api.js @@ -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) { diff --git a/frontend/src/services/socket.js b/frontend/src/services/socket.js index 84c5d5a..79fe2a6 100644 --- a/frontend/src/services/socket.js +++ b/frontend/src/services/socket.js @@ -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;