feat: closes #10296

asset_base_url in nconf
keep assetBaseUrl in config for backwards compat
isekai-main
Barış Soner Uşaklı 3 years ago
parent 5b0d4a8ec9
commit 58b5781cea

@ -434,7 +434,7 @@ ajaxify = window.ajaxify || {};
};
ajaxify.loadTemplate = function (template, callback) {
require([config.assetBaseUrl + '/templates/' + template + '.js'], callback, function (err) {
require([config.asset_base_url + '/templates/' + template + '.js'], callback, function (err) {
console.error('Unable to load template: ' + template);
throw err;
});

@ -3,7 +3,7 @@
(function (factory) {
function loadClient(language, namespace) {
return new Promise(function (resolve, reject) {
jQuery.getJSON([config.assetBaseUrl, 'language', language, namespace].join('/') + '.json?' + config['cache-buster'], function (data) {
jQuery.getJSON([config.asset_base_url, 'language', language, namespace].join('/') + '.json?' + config['cache-buster'], function (data) {
const payload = {
language: language,
namespace: namespace,

@ -14,6 +14,7 @@ const apiController = module.exports;
const relative_path = nconf.get('relative_path');
const upload_url = nconf.get('upload_url');
const asset_base_url = nconf.get('asset_base_url');
const socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket'];
const socketioOrigins = nconf.get('socket.io:origins');
const websocketAddress = nconf.get('socket.io:address') || '';
@ -22,7 +23,8 @@ apiController.loadConfig = async function (req) {
const config = {
relative_path,
upload_url,
assetBaseUrl: `${relative_path}/assets`,
asset_base_url,
assetBaseUrl: asset_base_url, // deprecate in 1.20.x
siteTitle: validator.escape(String(meta.config.title || meta.config.browserTitle || 'NodeBB')),
browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB')),
titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'),

@ -95,6 +95,7 @@ function loadConfig(configFile) {
nconf.set('secure', urlObject.protocol === 'https:');
nconf.set('use_port', !!urlObject.port);
nconf.set('relative_path', relativePath);
nconf.set('asset_base_url', `${relativePath}/assets`);
nconf.set('port', nconf.get('PORT') || nconf.get('port') || urlObject.port || (nconf.get('PORT_ENV_VAR') ? nconf.get(nconf.get('PORT_ENV_VAR')) : false) || 4567);
// cookies don't provide isolation by port: http://stackoverflow.com/a/16328399/122353

@ -38,6 +38,7 @@ nconf.defaults({
const urlObject = url.parse(nconf.get('url'));
const relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
nconf.set('relative_path', relativePath);
nconf.set('asset_base_url', `${relativePath}/assets`);
nconf.set('upload_path', path.join(nconf.get('base_dir'), nconf.get('upload_path')));
nconf.set('upload_url', '/assets/uploads');
nconf.set('url_parsed', urlObject);

Loading…
Cancel
Save