Skip to content

Commit 1e437ba

Browse files
committed
Use server port when proxying websockets
1 parent 12cf9c1 commit 1e437ba

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/daemon/group.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,9 @@ class Group extends EventEmitter {
365365
} else if (item.start) {
366366
target = `ws://127.0.0.1:${item.env.PORT}`
367367
} else {
368-
const { hostname } = url.parse(item.target)
369-
target = `ws://${hostname}`
368+
const { hostname, port } = url.parse(item.target)
369+
const targetPort = port || 80
370+
target = `ws://${hostname}:${targetPort}`
370371
}
371372
log(`WebSocket - ${host}${target}`)
372373
this._proxy.ws(req, socket, head, { target }, err => {

test/daemon/group.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test('group.handleUpgrade with proxy', t => {
3636
group.handleUpgrade(req, head, socket)
3737

3838
sinon.assert.calledWith(group._proxy.ws, req, head, socket, {
39-
target: `ws://${target}`
39+
target: `ws://${target}:80`
4040
})
4141
t.pass()
4242
})

0 commit comments

Comments
 (0)