Skip to content

Commit fe6fdfd

Browse files
feat: bind http server to localhost (socketio#54)
1 parent 51f77ea commit fe6fdfd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const app = require('express')();
22
const http = require('http').Server(app);
33
const io = require('socket.io')(http);
4+
const host = process.env.HOST || 'localhost';
45
const port = process.env.PORT || 3000;
56

67
app.get('/', (req, res) => {
@@ -13,6 +14,6 @@ io.on('connection', (socket) => {
1314
});
1415
});
1516

16-
http.listen(port, () => {
17-
console.log(`Socket.IO server running at http://localhost:${port}/`);
17+
http.listen(port, host, () => {
18+
console.log(`Socket.IO server running at http://${host}:${port}/`);
1819
});

0 commit comments

Comments
 (0)