diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index b1958c56c42..01b0292738c 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -431,6 +431,8 @@ "CAS_version": "CAS Version", "CAS_version_Description": "Only use a supported CAS version supported by your CAS SSO service.", "CDN_PREFIX": "CDN Prefix", + "CDN_PREFIX_ALL": "Use CDN Prefix for all assets", + "CDN_JSCSS_PREFIX": "CDN Prefix for JS/CSS", "Certificates_and_Keys": "Certificates and Keys", "Change_Room_Type": "Changing the Room Type", "Changing_email": "Changing email", diff --git a/packages/rocketchat-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js index aadb7dd52b2..4b3c019da54 100644 --- a/packages/rocketchat-lib/server/startup/settings.js +++ b/packages/rocketchat-lib/server/startup/settings.js @@ -754,6 +754,18 @@ RocketChat.settings.addGroup('General', function() { type: 'string', public: true, }); + this.add('CDN_PREFIX_ALL', true, { + type: 'boolean', + public: true, + }); + this.add('CDN_JSCSS_PREFIX', '', { + type: 'string', + public: true, + enableQuery: { + _id: 'CDN_PREFIX_ALL', + value: false, + }, + }); this.add('Force_SSL', false, { type: 'boolean', public: true, diff --git a/packages/rocketchat-lib/server/startup/settingsOnLoadCdnPrefix.js b/packages/rocketchat-lib/server/startup/settingsOnLoadCdnPrefix.js index 57aec430eca..d76ab7f7d76 100644 --- a/packages/rocketchat-lib/server/startup/settingsOnLoadCdnPrefix.js +++ b/packages/rocketchat-lib/server/startup/settingsOnLoadCdnPrefix.js @@ -5,14 +5,28 @@ function testWebAppInternals(fn) { typeof WebAppInternals !== 'undefined' && fn(WebAppInternals); } RocketChat.settings.onload('CDN_PREFIX', function(key, value) { - if (_.isString(value) && value.trim()) { + const useForAll = RocketChat.settings.get('CDN_PREFIX_ALL'); + if (_.isString(value) && value.trim() && useForAll) { return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(value)); } }); -Meteor.startup(function() { - const value = RocketChat.settings.get('CDN_PREFIX'); - if (_.isString(value) && value.trim()) { +RocketChat.settings.onload('CDN_JSCSS_PREFIX', function(key, value) { + const useForAll = RocketChat.settings.get('CDN_PREFIX_ALL'); + if (_.isString(value) && value.trim() && !useForAll) { return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(value)); } }); + +Meteor.startup(function() { + const cdnValue = RocketChat.settings.get('CDN_PREFIX'); + const useForAll = RocketChat.settings.get('CDN_PREFIX_ALL'); + const cdnJsCss = RocketChat.settings.get('CDN_JSCSS_PREFIX'); + if (_.isString(cdnValue) && cdnValue.trim()) { + if (useForAll) { + return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(cdnValue)); + } else if (_.isString(cdnJsCss) && cdnJsCss.trim()) { + return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(cdnJsCss)); + } + } +});