Skip to content

Commit af5c36d

Browse files
committedMar 26, 2024·
update
1 parent 7edbd8c commit af5c36d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed
 

‎bin/server.cjs

+5-7
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ const server = http.createServer((_request, response) => {
2020
wss.on('connection', setupWSConnection)
2121

2222
server.on('upgrade', (request, socket, head) => {
23-
// You may check auth of request here..
23+
// You may check auth of request here.. Call `wss.HandleUpgrade` *after* you
24+
// checked whether the client has access (e.g. by checking cookies, or url
25+
// parameters).
2426
// See https://github.com/websockets/ws#client-authentication
25-
/**
26-
* @param {any} ws
27-
*/
28-
const handleAuth = ws => {
27+
wss.handleUpgrade(request, socket, head, /** @param {any} ws */ ws => {
2928
wss.emit('connection', ws, request)
30-
}
31-
wss.handleUpgrade(request, socket, head, handleAuth)
29+
})
3230
})
3331

3432
server.listen(port, host, () => {

0 commit comments

Comments
 (0)
Please sign in to comment.