Add field to configure the reverse proxy

part of #596
This commit is contained in:
Girish Ramakrishnan
2019-10-13 18:22:03 -07:00
parent 7383cc4e90
commit 9c12f1fe15
11 changed files with 177 additions and 42 deletions

View File

@@ -21,7 +21,7 @@ exports = module.exports = {
setMemoryLimit: setMemoryLimit,
setAutomaticBackup: setAutomaticBackup,
setAutomaticUpdate: setAutomaticUpdate,
setRobotsTxt: setRobotsTxt,
setReverseProxyConfig: setReverseProxyConfig,
setCertificate: setCertificate,
setDebugMode: setDebugMode,
setEnvironment: setEnvironment,
@@ -255,13 +255,19 @@ function setAutomaticUpdate(req, res, next) {
});
}
function setRobotsTxt(req, res, next) {
function setReverseProxyConfig(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.params.id, 'string');
if (req.body.robotsTxt !== null && typeof req.body.robotsTxt !== 'string') return next(new HttpError(400, 'robotsTxt is not a string'));
apps.setRobotsTxt(req.params.id, req.body.robotsTxt, auditSource.fromRequest(req), function (error) {
if (!Array.isArray(req.body.frameAncestors)) return next(new HttpError(400, 'frameAncestors must be an array'));
if (req.body.frameAncestors.some(fa => typeof fa !== 'string')) return next(new HttpError(400, 'frameAncestors array must contain array of strings'));
if (!Array.isArray(req.body.hideHeaders)) return next(new HttpError(400, 'hideHeaders must be an array'));
if (req.body.hideHeaders.some(h => typeof h !== 'string')) return next(new HttpError(400, 'hideHeaders array must contain array of strings'));
apps.setReverseProxyConfig(req.params.id, req.body, auditSource.fromRequest(req), function (error) {
if (error) return next(toHttpError(error));
next(new HttpSuccess(200, {}));