From 9a71372c366b96e9df00b3f2a0d9cfaa2d8b3c3c Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 24 May 2022 09:28:11 +0100 Subject: [PATCH] Merge pull request #8071 from overleaf/jpa-clsi-zonal [misc] prefix output file downloads with /zone/X GitOrigin-RevId: ba59e97ae0284c68ba551dd49dc5d3daa4d61aa9 --- services/clsi/app/js/CompileController.js | 2 +- services/clsi/config/settings.defaults.js | 5 +++++ services/clsi/test/unit/js/CompileControllerTests.js | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/services/clsi/app/js/CompileController.js b/services/clsi/app/js/CompileController.js index dcf56d695b..a5dc885da0 100644 --- a/services/clsi/app/js/CompileController.js +++ b/services/clsi/app/js/CompileController.js @@ -125,7 +125,7 @@ module.exports = CompileController = { outputFiles: outputFiles.map(file => { return { url: - `${Settings.apis.clsi.url}/project/${request.project_id}` + + `${Settings.apis.clsi.outputUrl}/project/${request.project_id}` + (request.user_id != null ? `/user/${request.user_id}` : '') + diff --git a/services/clsi/config/settings.defaults.js b/services/clsi/config/settings.defaults.js index b724bb5493..9a86dd36dd 100644 --- a/services/clsi/config/settings.defaults.js +++ b/services/clsi/config/settings.defaults.js @@ -34,7 +34,12 @@ module.exports = { }, apis: { clsi: { + // Internal requests (used by tests only at the time of writing). url: `http://${process.env.CLSI_HOST || 'localhost'}:3013`, + // External url prefix for output files, e.g. for requests via load-balancers. + outputUrl: `http://${process.env.CLSI_HOST || 'localhost'}:3013${ + process.env.ZONE ? `/zone/${process.env.ZONE}` : '' + }`, }, clsiPerf: { host: `${process.env.CLSI_PERF_HOST || 'localhost'}:${ diff --git a/services/clsi/test/unit/js/CompileControllerTests.js b/services/clsi/test/unit/js/CompileControllerTests.js index 792c7adc7e..8d66948b1f 100644 --- a/services/clsi/test/unit/js/CompileControllerTests.js +++ b/services/clsi/test/unit/js/CompileControllerTests.js @@ -69,7 +69,7 @@ describe('CompileController', function () { '@overleaf/settings': (this.Settings = { apis: { clsi: { - url: 'http://clsi.example.com', + outputUrl: 'http://clsi.example.com', }, }, }), @@ -157,7 +157,7 @@ describe('CompileController', function () { timings: this.timings, outputFiles: this.output_files.map(file => { return { - url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`, + url: `${this.Settings.apis.clsi.outputUrl}/project/${this.project_id}/build/${file.build}/output/${file.path}`, ...file, } }), @@ -198,7 +198,7 @@ describe('CompileController', function () { timings: this.timings, outputFiles: this.output_files.map(file => { return { - url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`, + url: `${this.Settings.apis.clsi.outputUrl}/project/${this.project_id}/build/${file.build}/output/${file.path}`, ...file, } }), @@ -240,7 +240,7 @@ describe('CompileController', function () { timings: this.timings, outputFiles: this.output_files.map(file => { return { - url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`, + url: `${this.Settings.apis.clsi.outputUrl}/project/${this.project_id}/build/${file.build}/output/${file.path}`, ...file, } }),