mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: closes #10296
asset_base_url in nconf keep assetBaseUrl in config for backwards compat
This commit is contained in:
@@ -434,7 +434,7 @@ ajaxify = window.ajaxify || {};
|
|||||||
};
|
};
|
||||||
|
|
||||||
ajaxify.loadTemplate = function (template, callback) {
|
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);
|
console.error('Unable to load template: ' + template);
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
(function (factory) {
|
(function (factory) {
|
||||||
function loadClient(language, namespace) {
|
function loadClient(language, namespace) {
|
||||||
return new Promise(function (resolve, reject) {
|
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 = {
|
const payload = {
|
||||||
language: language,
|
language: language,
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const apiController = module.exports;
|
|||||||
|
|
||||||
const relative_path = nconf.get('relative_path');
|
const relative_path = nconf.get('relative_path');
|
||||||
const upload_url = nconf.get('upload_url');
|
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 socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket'];
|
||||||
const socketioOrigins = nconf.get('socket.io:origins');
|
const socketioOrigins = nconf.get('socket.io:origins');
|
||||||
const websocketAddress = nconf.get('socket.io:address') || '';
|
const websocketAddress = nconf.get('socket.io:address') || '';
|
||||||
@@ -22,7 +23,8 @@ apiController.loadConfig = async function (req) {
|
|||||||
const config = {
|
const config = {
|
||||||
relative_path,
|
relative_path,
|
||||||
upload_url,
|
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')),
|
siteTitle: validator.escape(String(meta.config.title || meta.config.browserTitle || 'NodeBB')),
|
||||||
browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB')),
|
browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB')),
|
||||||
titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'),
|
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('secure', urlObject.protocol === 'https:');
|
||||||
nconf.set('use_port', !!urlObject.port);
|
nconf.set('use_port', !!urlObject.port);
|
||||||
nconf.set('relative_path', relativePath);
|
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);
|
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
|
// 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 urlObject = url.parse(nconf.get('url'));
|
||||||
const relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
|
const relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
|
||||||
nconf.set('relative_path', relativePath);
|
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_path', path.join(nconf.get('base_dir'), nconf.get('upload_path')));
|
||||||
nconf.set('upload_url', '/assets/uploads');
|
nconf.set('upload_url', '/assets/uploads');
|
||||||
nconf.set('url_parsed', urlObject);
|
nconf.set('url_parsed', urlObject);
|
||||||
|
|||||||
Reference in New Issue
Block a user