Skip to content

Commit 593a0d1

Browse files
Merge pull request #2314 from GValeriy/master
fix: Restrict subscriptions WS server to add listeners only to its own path
2 parents ca8cabb + 64c59fa commit 593a0d1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/graphql/lib/services/gql-subscription.service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ export class GqlSubscriptionService {
138138
? this.subTransWs
139139
: this.wss;
140140

141-
wss.handleUpgrade(req, socket, head, (ws) => {
142-
wss.emit('connection', ws, req);
143-
});
141+
if (req.url?.startsWith(wss.options.path)) {
142+
wss.handleUpgrade(req, socket, head, (ws) => {
143+
wss.emit('connection', ws, req);
144+
});
145+
}
144146
});
145147
}
146148

0 commit comments

Comments
 (0)