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, } }),