2015-03-09 10:09:09 -04:00
|
|
|
settings = require "settings-sharelatex"
|
|
|
|
|
|
|
|
httpProxy = require('http-proxy');
|
|
|
|
proxy = httpProxy.createProxyServer({
|
|
|
|
target: settings.apis.realTime.url
|
2015-03-20 15:08:35 -04:00
|
|
|
})
|
|
|
|
wsProxy = httpProxy.createProxyServer({
|
|
|
|
target: settings.apis.realTime.url.replace("http://", "ws://")
|
2015-03-09 10:09:09 -04:00
|
|
|
ws: true
|
|
|
|
})
|
|
|
|
|
|
|
|
module.exports =
|
2015-06-30 09:38:32 -04:00
|
|
|
apply: (webRouter, apiRouter) ->
|
|
|
|
webRouter.all /\/socket\.io\/.*/, (req, res, next) ->
|
2015-03-20 15:08:35 -04:00
|
|
|
proxy.web req, res, next
|
|
|
|
|
|
|
|
setTimeout () ->
|
|
|
|
Server = require "../../infrastructure/Server"
|
|
|
|
Server.server.on "upgrade", (req, socket, head) ->
|
|
|
|
wsProxy.ws req, socket, head
|
|
|
|
, 0
|