Skip to content

Commit

Permalink
Use server port when proxying websockets
Browse files Browse the repository at this point in the history
  • Loading branch information
drampelt committed Aug 20, 2018
1 parent 12cf9c1 commit 1e437ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/daemon/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion test/daemon/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down

0 comments on commit 1e437ba

Please sign in to comment.