Handle optional non-localhost endpoint in web signaling server

This commit is contained in:
Paul-Louis Ageneau
2020-09-24 15:07:27 +02:00
parent d288885a89
commit 30dc229477

View File

@ -98,8 +98,10 @@ wsServer.on('request', (req) => {
clients[id] = conn;
});
const hostname = '127.0.0.1';
const port = 8000;
const endpoint = process.env.PORT || '8000';
const splitted = endpoint.split(':');
const port = splitted.pop();
const hostname = splitted.join(':') || '127.0.0.1';
httpServer.listen(port, hostname, () => {
console.log(`Server listening on ${hostname}:${port}`);