mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
20 lines
621 B
CoffeeScript
20 lines
621 B
CoffeeScript
settings = require "settings-sharelatex"
|
|
Errors = require '../Errors/Errors'
|
|
httpProxy = require 'express-http-proxy'
|
|
URL = require 'url'
|
|
|
|
module.exports =
|
|
call: (basePath) ->
|
|
analyticsUrl = settings?.apis?.analytics?.url
|
|
if analyticsUrl?
|
|
httpProxy(analyticsUrl,
|
|
proxyReqPathResolver: (req) ->
|
|
requestPath = URL.parse(req.url).path
|
|
"#{basePath}#{requestPath}"
|
|
proxyReqOptDecorator: (proxyReqOpts, srcReq) ->
|
|
proxyReqOpts.headers = {} # unset all headers
|
|
proxyReqOpts
|
|
)
|
|
else
|
|
(req, res, next) ->
|
|
next(new Errors.ServiceNotConfiguredError('Analytics service not configured'))
|