Node.js based forum software built for the modern web
fixed oddities in base_url and url generation for subdirectoried instances of NodeBB
Julian Lam3c4b2c8075cb
diff --git a/app.js b/app.jsindex e0c499ae7e..116c33f479 100644--- a/app.js+++ b/app.js@@ -35,8 +35,9 @@ console.log('Info: This is free software, and you are welcome to redistribute itconsole.log('Info: ===');if (!nconf.get('setup') && nconf.get('base_url')) {- nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + '/');+ nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + '/');nconf.set('upload_url', nconf.get('url') + 'uploads/');+ console.log('NCONF CHECK', nconf.get('base_url'), nconf.get('upload_url'), nconf.get('url'));global.nconf = nconf;console.log('Info: Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using Redis store at ' + nconf.get('redis:host') + ':' + nconf.get('redis:port') + '.');diff --git a/src/install.js b/src/install.jsindex cfb5c63aae..311d3ef0a3 100644--- a/src/install.js+++ b/src/install.js@@ -81,6 +81,7 @@ var async = require('async'),relative_path: relative_path};+ server_conf.base_url = protocol + '//' + host;server_conf.relative_path = relative_path;install.save(server_conf, client_conf, callback);diff --git a/src/sitemap.js b/src/sitemap.jsindex 44378a215d..d2d5158018 100644--- a/src/sitemap.js+++ b/src/sitemap.js@@ -6,17 +6,14 @@ var path = require('path'),topics = require('./topics'),sitemap = {getStaticUrls: function(callback) {- var relative_path = global.nconf.get('relative_path');-callback(null, [- { url: relative_path, changefreq: 'weekly', priority: '0.6' },- { url: path.join(relative_path, 'recent'), changefreq: 'daily', priority: '0.4' },- { url: path.join(relative_path, 'users'), changefreq: 'daily', priority: '0.4' }+ { url: '', changefreq: 'weekly', priority: '0.6' },+ { url: 'recent', changefreq: 'daily', priority: '0.4' },+ { url: 'users', changefreq: 'daily', priority: '0.4' }]);},getDynamicUrls: function(callback) {- var relative_path = global.nconf.get('relative_path'),- returnUrls = [];+ var returnUrls = [];async.parallel([function(next) {@@ -24,7 +21,7 @@ var path = require('path'),categories.getAllCategories(function(data) {data.categories.forEach(function(category) {categoryUrls.push({- url: path.join(relative_path, 'category', category.slug),+ url: path.join('category', category.slug),changefreq: 'weekly',priority: '0.4'});@@ -38,7 +35,7 @@ var path = require('path'),topics.getAllTopics(null, null, function(topics) {topics.forEach(function(topic) {topicUrls.push({- url: path.join(relative_path, 'topic', topic.slug),+ url: path.join('topic', topic.slug),changefreq: 'daily',priority: '0.6'});@@ -59,7 +56,7 @@ var path = require('path'),async.parallel([sitemap.getStaticUrls, sitemap.getDynamicUrls], function(err, urls) {var urls = urls[0].concat(urls[1]),map = sm.createSitemap({- hostname: global.nconf.get('base_url') + (global.nconf.get('use_port') ? ':' + global.nconf.get('port') : '') + '/',+ hostname: global.nconf.get('url'),cacheTime: 600000,urls: urls}),