Skip to content

Commit 2d63b18

Browse files
authored
Update index.js
1 parent 9f65756 commit 2d63b18

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

server/index.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,6 @@ async function setupProjectsWatcher() {
130130
}
131131
}
132132

133-
// Get the first non-localhost IP address
134-
function getServerIP() {
135-
const interfaces = os.networkInterfaces();
136-
for (const name of Object.keys(interfaces)) {
137-
for (const iface of interfaces[name]) {
138-
if (iface.family === 'IPv4' && !iface.internal) {
139-
return iface.address;
140-
}
141-
}
142-
}
143-
return 'localhost';
144-
}
145133

146134
const app = express();
147135
const server = http.createServer(app);
@@ -188,9 +176,7 @@ app.use(express.static(path.join(__dirname, '../dist')));
188176

189177
// API Routes (protected)
190178
app.get('/api/config', authenticateToken, (req, res) => {
191-
// Always use the server's actual IP and port for WebSocket connections
192-
const serverIP = getServerIP();
193-
const host = `${serverIP}:${PORT}`;
179+
const host = req.headers.host || `${req.hostname}:${PORT}`;
194180
const protocol = req.protocol === 'https' || req.get('x-forwarded-proto') === 'https' ? 'wss' : 'ws';
195181

196182
console.log('Config API called - Returning host:', host, 'Protocol:', protocol);
@@ -1006,4 +992,4 @@ async function startServer() {
1006992
}
1007993
}
1008994

1009-
startServer();
995+
startServer();

0 commit comments

Comments
 (0)