mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
moved nconf setup to loadConfig, fixed upload_url
This commit is contained in:
22
app.js
22
app.js
@@ -95,10 +95,22 @@ function loadConfig() {
|
|||||||
nconf.defaults({
|
nconf.defaults({
|
||||||
base_dir: __dirname,
|
base_dir: __dirname,
|
||||||
themes_path: path.join(__dirname, 'node_modules'),
|
themes_path: path.join(__dirname, 'node_modules'),
|
||||||
upload_url: nconf.get('relative_path') + '/uploads/',
|
|
||||||
views_dir: path.join(__dirname, 'public/templates')
|
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
|
// Ensure themes_path is a full filepath
|
||||||
nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
|
nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
|
||||||
nconf.set('core_templates_path', path.join(__dirname, 'src/views'));
|
nconf.set('core_templates_path', path.join(__dirname, 'src/views'));
|
||||||
@@ -108,14 +120,6 @@ function loadConfig() {
|
|||||||
function start() {
|
function start() {
|
||||||
loadConfig();
|
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') {
|
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
|
||||||
winston.info('Time: %s', (new Date()).toString());
|
winston.info('Time: %s', (new Date()).toString());
|
||||||
winston.info('Initializing NodeBB v%s', pkg.version);
|
winston.info('Initializing NodeBB v%s', pkg.version);
|
||||||
|
|||||||
Reference in New Issue
Block a user