mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 13:49:00 +02:00
Actually proxy websocket connections
This commit is contained in:
@@ -3,10 +3,19 @@ settings = require "settings-sharelatex"
|
||||
httpProxy = require('http-proxy');
|
||||
proxy = httpProxy.createProxyServer({
|
||||
target: settings.apis.realTime.url
|
||||
})
|
||||
wsProxy = httpProxy.createProxyServer({
|
||||
target: settings.apis.realTime.url.replace("http://", "ws://")
|
||||
ws: true
|
||||
})
|
||||
|
||||
module.exports =
|
||||
apply: (app) ->
|
||||
app.all /\/socket\.io\/.*/, (req, res, next) ->
|
||||
proxy.web req, res, next
|
||||
proxy.web req, res, next
|
||||
|
||||
setTimeout () ->
|
||||
Server = require "../../infrastructure/Server"
|
||||
Server.server.on "upgrade", (req, socket, head) ->
|
||||
wsProxy.ws req, socket, head
|
||||
, 0
|
||||
@@ -81,7 +81,6 @@ block content
|
||||
//- and doesn't prematurely end the script tag.
|
||||
script(type='text/javascript').
|
||||
window.project_id = "!{project_id}";
|
||||
window.websocketsUrl = "!{settings.websocketsUrl}";
|
||||
window.userSettings = !{JSON.stringify(userSettings).replace(/\//g, '\\/')};
|
||||
window.user = !{JSON.stringify(user).replace(/\//g, '\\/')};
|
||||
window.csrfToken = "!{csrfToken}";
|
||||
|
||||
@@ -105,14 +105,6 @@ module.exports =
|
||||
|
||||
templates:
|
||||
user_id: process.env.TEMPLATES_USER_ID or "5395eb7aad1f29a88756c7f2"
|
||||
|
||||
# The websocket layer of ShareLaTeX runs as separate service.
|
||||
# When running locally or in development, you can point the client to this
|
||||
# service directly. If you are running behind a reverse proxy (Nginx, etc)
|
||||
# then websocketsUrl should be the same as siteUrl, with your reverse
|
||||
# proxy responible for sending websocket traffic to the websocket service
|
||||
# rather than connecting directly.
|
||||
websocketsUrl: "http://localhost:3026"
|
||||
|
||||
# Where your instance of ShareLaTeX can be found publically. Used in emails
|
||||
# that are sent out, generated links, etc.
|
||||
|
||||
@@ -22,7 +22,7 @@ define [], () ->
|
||||
@$scope.$on "editor:change", () =>
|
||||
@lastUpdated = new Date()
|
||||
|
||||
@ide.socket = io.connect window.websocketsUrl,
|
||||
@ide.socket = io.connect null,
|
||||
reconnect: false
|
||||
"force new connection": true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user