From 2fbaed9cdf5785be3399ab9e2d747f68975b6a54 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 3 Dec 2014 01:10:45 -0500 Subject: [PATCH] moved nconf setup to loadConfig, fixed upload_url --- app.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) 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);