File tree Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Original file line number Diff line number Diff line change @@ -130,18 +130,6 @@ async function setupProjectsWatcher() {
130
130
}
131
131
}
132
132
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
- }
145
133
146
134
const app = express ( ) ;
147
135
const server = http . createServer ( app ) ;
@@ -188,9 +176,7 @@ app.use(express.static(path.join(__dirname, '../dist')));
188
176
189
177
// API Routes (protected)
190
178
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 } ` ;
194
180
const protocol = req . protocol === 'https' || req . get ( 'x-forwarded-proto' ) === 'https' ? 'wss' : 'ws' ;
195
181
196
182
console . log ( 'Config API called - Returning host:' , host , 'Protocol:' , protocol ) ;
@@ -1006,4 +992,4 @@ async function startServer() {
1006
992
}
1007
993
}
1008
994
1009
- startServer ( ) ;
995
+ startServer ( ) ;
You can’t perform that action at this time.
0 commit comments