Soham Waghmare commited on
Commit
63ec0ab
·
1 Parent(s): f87c3db
frontend/next.config.mjs CHANGED
@@ -1,4 +1,6 @@
1
  /** @type {import('next').NextConfig} */
2
- const nextConfig = {};
 
 
3
 
4
  export default nextConfig;
 
1
  /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ output: "export",
4
+ };
5
 
6
  export default nextConfig;
frontend/src/lib/socket.ts CHANGED
@@ -2,14 +2,18 @@ import { io, Socket } from "socket.io-client";
2
 
3
  let socket: Socket | null = null;
4
 
5
- export const initializeSocket = (url: string = process.env.NEXT_PUBLIC_KNET_BACKEND!) => {
6
- url = process.env.NEXT_PUBLIC_KNET_BACKEND || "http://127.0.0.1:5000";
 
 
 
7
  if (!socket) {
8
- socket = io(url, {
9
  transports: ["websocket"],
10
  reconnection: true,
11
  reconnectionAttempts: 5,
12
  reconnectionDelay: 1000,
 
13
  });
14
  }
15
  return socket;
 
2
 
3
  let socket: Socket | null = null;
4
 
5
+ export const initializeSocket = (url?: string) => {
6
+ // In production (Docker), use the same host where the frontend is served
7
+ // This will route through nginx proxy to the backend
8
+ const socketUrl = url || process.env.NEXT_PUBLIC_KNET_BACKEND || (typeof window !== 'undefined' ? window.location.origin : "http://127.0.0.1:3000");
9
+
10
  if (!socket) {
11
+ socket = io(socketUrl, {
12
  transports: ["websocket"],
13
  reconnection: true,
14
  reconnectionAttempts: 5,
15
  reconnectionDelay: 1000,
16
+ path: "/socket.io/",
17
  });
18
  }
19
  return socket;