From 1e437bacd9d10d41572bf057f4e4693639ee796f Mon Sep 17 00:00:00 2001 From: Daniel Rampelt Date: Tue, 16 Jan 2018 13:44:54 -0500 Subject: [PATCH] Use server port when proxying websockets --- src/daemon/group.js | 5 +++-- test/daemon/group.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/daemon/group.js b/src/daemon/group.js index d2d60d9d..e4c9540b 100644 --- a/src/daemon/group.js +++ b/src/daemon/group.js @@ -365,8 +365,9 @@ class Group extends EventEmitter { } else if (item.start) { target = `ws://127.0.0.1:${item.env.PORT}` } else { - const { hostname } = url.parse(item.target) - target = `ws://${hostname}` + const { hostname, port } = url.parse(item.target) + const targetPort = port || 80 + target = `ws://${hostname}:${targetPort}` } log(`WebSocket - ${host} → ${target}`) this._proxy.ws(req, socket, head, { target }, err => { diff --git a/test/daemon/group.js b/test/daemon/group.js index b0517679..d682cf7c 100644 --- a/test/daemon/group.js +++ b/test/daemon/group.js @@ -36,7 +36,7 @@ test('group.handleUpgrade with proxy', t => { group.handleUpgrade(req, head, socket) sinon.assert.calledWith(group._proxy.ws, req, head, socket, { - target: `ws://${target}` + target: `ws://${target}:80` }) t.pass() })