mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-06 04:51:00 +00:00
17 lines
462 B
CoffeeScript
17 lines
462 B
CoffeeScript
|
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"
|
||
|
upstream = request(redirectUrl)
|
||
|
upstream.on "error", (error) ->
|
||
|
logger.error err: error, "error in OldAssetProxy"
|
||
|
upstream.pipe(res)
|
||
|
else
|
||
|
next()
|