Skip to content

Node.js based forum software built for the modern web

moved nconf setup to loadConfig, fixed upload_url

barisusakli2fbaed9cdf57
diff --git a/app.js b/app.js
index 414021c183..8d8c06ed88 100644
--- a/app.js
+++ b/app.js
@@ -95,10 +95,22 @@ function loadConfig() {
nconf.defaults({
base_dir: __dirname,
themes_path: path.join(__dirname, 'node_modules'),
- upload_url: nconf.get('relative_path') + '/uploads/',
views_dir: path.join(__dirname, 'public/templates')
});
+ // nconf defaults, if not set in config
+ if (!nconf.get('upload_path')) {
+ nconf.set('upload_path', '/public/uploads');
+ }
+ // Parse out the relative_url and other goodies from the configured URL
+ var urlObject = url.parse(nconf.get('url'));
+ var relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
+ nconf.set('use_port', !!urlObject.port);
+ nconf.set('relative_path', relativePath);
+ nconf.set('port', urlObject.port || nconf.get('port') || nconf.get('PORT') || 4567);
+ nconf.set('upload_url', relativePath + '/uploads/');
+
+
// Ensure themes_path is a full filepath
nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
nconf.set('core_templates_path', path.join(__dirname, 'src/views'));
@@ -108,14 +120,6 @@ function loadConfig() {
function start() {
loadConfig();
- // nconf defaults, if not set in config
- if (!nconf.get('upload_path')) nconf.set('upload_path', '/public/uploads');
- // Parse out the relative_url and other goodies from the configured URL
- var urlObject = url.parse(nconf.get('url'));
- nconf.set('use_port', !!urlObject.port);
- nconf.set('relative_path', urlObject.pathname !== '/' ? urlObject.pathname : '');
- nconf.set('port', urlObject.port || nconf.get('port') || nconf.get('PORT') || 4567);
-
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
winston.info('Time: %s', (new Date()).toString());
winston.info('Initializing NodeBB v%s', pkg.version);