1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2024-12-19 12:25:09 -05:00
overleaf/services/web/app/coffee/infrastructure/OldAssetProxy.coffee

17 lines
462 B
CoffeeScript
Raw Normal View History

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"
2014-11-24 08:58:41 -05:00
upstream = request(redirectUrl)
upstream.on "error", (error) ->
logger.error err: error, "error in OldAssetProxy"
upstream.pipe(res)
else
next()