diff --git a/Dockerfile b/Dockerfile index d755ed1..3d20c2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ WORKDIR /app/backend COPY --from=frontend-build /app/frontend/build ./src/main/resources/static COPY backend/pom.xml . COPY backend/src ./src -RUN mvn clean package +RUN mvn -B package # Final image FROM openjdk:17-slim diff --git a/frontend/src/utils/websocket.js b/frontend/src/utils/websocket.js index bf5e521..027e415 100644 --- a/frontend/src/utils/websocket.js +++ b/frontend/src/utils/websocket.js @@ -26,7 +26,8 @@ class WebSocketService { heartbeatOutgoing: 2000, webSocketFactory: () => { const isProd = process.env.NODE_ENV === 'production'; - const url = `${isProd ? "https" : "http"}://localhost:8080/ws?username=${this.username}`; + const host = isProd ? window.location.hostname : 'localhost:8080'; + const url = `${isProd ? "https" : "http"}://${host}/ws?username=${this.username}`; const socket = new SockJS(url); // Update with backend URL socket.onopen = () => console.log('SockJS connection open'); return socket;