mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
20 lines
655 B
CoffeeScript
20 lines
655 B
CoffeeScript
logger = require "logger-sharelatex"
|
|
request = require "request"
|
|
settings = require "settings-sharelatex"
|
|
AuthenticationController = require "../Authentication/AuthenticationController"
|
|
|
|
module.exports = HistoryController =
|
|
proxyToHistoryApi: (req, res, next = (error) ->) ->
|
|
user_id = AuthenticationController.getLoggedInUserId req
|
|
url = settings.apis.trackchanges.url + req.url
|
|
logger.log url: url, "proxying to track-changes api"
|
|
getReq = request(
|
|
url: url
|
|
method: req.method
|
|
headers:
|
|
"X-User-Id": user_id
|
|
)
|
|
getReq.pipe(res)
|
|
getReq.on "error", (error) ->
|
|
logger.error err: error, "track-changes API error"
|
|
next(error)
|