Skip to content

Commit d5f2b70

Browse files
committed
- adds mandatory explicit CORS configuration for socket.io
1 parent b1e694a commit d5f2b70

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

helpers/socketHelper.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import express from 'express';
22
import http from 'http';
33
import io from 'socket.io';
4+
import { subscriptionConfiguration, msalConfiguration } from '../constants';
45

56
const socketServer = http.createServer(express);
6-
export const ioServer = io(socketServer);
7+
export const ioServer = io(socketServer, {
8+
cors: {
9+
origin: [
10+
msalConfiguration.redirectUri.substring(0, msalConfiguration.redirectUri.lastIndexOf('/')),
11+
subscriptionConfiguration.notificationUrl.substring(0, subscriptionConfiguration.notificationUrl.lastIndexOf('/'))],
12+
methods: ['GET', 'POST']
13+
}
14+
});
715

816
socketServer.listen(3001);
917

0 commit comments

Comments
 (0)