mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-08 16:50:44 +02:00
c6c62088cc
GitOrigin-RevId: 4e9d3176b4b5a5504afc102e569a27d7788864a3
29 lines
761 B
JavaScript
29 lines
761 B
JavaScript
import settings from '@overleaf/settings'
|
|
import Errors from '../Errors/Errors.js'
|
|
import httpProxy from 'express-http-proxy'
|
|
|
|
export default {
|
|
call(basePath) {
|
|
if (!settings.apis.analytics) {
|
|
return (req, res, next) =>
|
|
next(
|
|
new Errors.ServiceNotConfiguredError(
|
|
'Analytics service not configured'
|
|
)
|
|
)
|
|
}
|
|
|
|
return httpProxy(settings.apis.analytics.url, {
|
|
proxyReqPathResolver(req) {
|
|
// req.url is the part of the path that comes after the mount point in
|
|
// app.use()
|
|
return `${basePath}${req.url}`
|
|
},
|
|
proxyReqOptDecorator(proxyReqOpts, srcReq) {
|
|
proxyReqOpts.headers = {} // unset all headers
|
|
return proxyReqOpts
|
|
},
|
|
})
|
|
},
|
|
}
|