added asset proxying from templates in, used for old images etc which people linked to

This commit is contained in:
Henry Oswald 2014-07-01 16:00:42 +01:00
parent 978e3262b5
commit 8f6dac77d0
3 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,13 @@
settings = require("settings-sharelatex")
logger = require("logger-sharelatex")
request = require("request")
module.exports = (req, res, next)->
requestedUrl = req.url
redirectUrl = settings.proxyUrls[requestedUrl]
if redirectUrl?
logger.log redirectUrl:redirectUrl, reqUrl:req.url, "proxying url"
request(redirectUrl).pipe(res)
else
next()

View file

@ -17,6 +17,7 @@ cookieParser = express.cookieParser(Settings.security.sessionSecret)
oneDayInMilliseconds = 86400000
ReferalConnect = require('../Features/Referal/ReferalConnect')
RedirectManager = require("./RedirectManager")
OldAssetProxy = require("./OldAssetProxy")
metrics.mongodb.monitor(Path.resolve(__dirname + "/../../../node_modules/mongojs/node_modules/mongodb"), logger)
metrics.mongodb.monitor(Path.resolve(__dirname + "/../../../node_modules/mongoose/node_modules/mongodb"), logger)
@ -76,6 +77,7 @@ app.configure 'production', ->
app.use metrics.http.monitor(logger)
app.use RedirectManager
app.use OldAssetProxy
app.use (req, res, next)->
metrics.inc "http-request"

View file

@ -269,3 +269,5 @@ module.exports =
redirects:
"/templates/index": "/templates/"
proxyUrls: {}