Skip to content

Commit

Permalink
Merge pull request #2291 from botpress/ya-socket-custom
Browse files Browse the repository at this point in the history
fix(core): socket.io correctly supports custom paths
  • Loading branch information
slvnperron committed Aug 27, 2019
2 parents b817b25 + 9f59bf5 commit 8318c56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/bp/core/services/realtime/index.ts
Expand Up @@ -51,6 +51,7 @@ export default class RealtimeService {
installOnHttpServer(server: Server) {
const io: socketio.Server = socketio(server, {
transports: ['websocket', 'polling'],
path: `${process.ROOT_PATH}/socket.io`,
origins: '*:*',
serveClient: false
})
Expand Down
6 changes: 4 additions & 2 deletions src/bp/ui-studio/src/web/util/EventBus.ts
Expand Up @@ -58,11 +58,13 @@ class EventBus extends EventEmitter2 {
}

const socketUrl = window['BP_SOCKET_URL'] || window.location.origin
const transports = ['websocket', 'polling']
const getPath = type => `${window['ROOT_PATH']}/socket.io/${type}`

this.adminSocket = io(socketUrl + '/admin', { query, transports: ['websocket', 'polling'] })
this.adminSocket = io(socketUrl, { query, transports, path: getPath('admin') })
this.adminSocket.on('event', this.dispatchSocketEvent)

this.guestSocket = io(socketUrl + '/guest', { query, transports: ['websocket', 'polling'] })
this.guestSocket = io(socketUrl, { query, transports, path: getPath('guest') })
this.guestSocket.on('event', this.dispatchSocketEvent)
}
}
Expand Down

0 comments on commit 8318c56

Please sign in to comment.