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:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user