Skip to content

Commit 8352092

Browse files
authored
Merge pull request #33 from RonasIT/PRD-2143-add-websocket-extra-headers
PRD-2143: Add extra origin header for websocket
2 parents 2968076 + 2ee3557 commit 8352092

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

libs/shared/data-access/websocket/src/service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ export class SocketService {
1717

1818
public init(token: string, onConnect: () => void, onDisconnect: () => void): void {
1919
if (this._socket) return;
20+
const apiUrl = getApiUrl();
2021

2122
this._socket = io(getApiUrl(), {
2223
path: webSocketConfig.path,
2324
transports: webSocketConfig.transports,
2425
auth: { token },
26+
// NOTE: Workaround required for the socket to connect to the backend, which rejects WS connections without this header.
27+
extraHeaders: {
28+
Origin: apiUrl,
29+
},
2530
});
2631

2732
this._socket.on(SocketState.CONNECT, () => {

0 commit comments

Comments
 (0)