feat(core): add configure item to set setDefaultValueOnIndex

set app.domain and announce.url on renderer index
if false, app.domain and announce.url used these config settings value
if true, app.domain and announce.url used req.app.get('domain') || req.headers.host
if web server used proxyPass setting, this should set to false
This commit is contained in:
OldHawk
2018-01-07 10:28:21 +08:00
parent 19e1990abc
commit 959a658aae
3 changed files with 18 additions and 10 deletions

View File

@@ -14,7 +14,7 @@ module.exports = {
host: process.env.HOST || '0.0.0.0',
// DOMAIN config should be set to the fully qualified application accessible
// URL. For example: https://www.myapp.com (including port if required).
domain: process.env.DOMAIN || 'chd.im:3000',
domain: process.env.DOMAIN || 'chd.im',
// Session Cookie settings
sessionCookie: {
// session expiration is set by default to 24 hours

View File

@@ -13,13 +13,18 @@ module.exports = {
* @cronTimeZone: timezone of cron
* @showDebugLog: if true, will console.log all debug info at server side and client side. when your site is prod env, please change this
* value to false, then console.log info is not output
* @setDefaultValueOnIndex: set app.domain and announce.url on renderer index
* if false, app.domain and announce.url used these config settings value
* if true, app.domain and announce.url used req.app.get('domain') || req.headers.host
* if web server used proxyPass setting, this should set to false
*/
app: {
name: 'CHD.im',
domain: 'http://chd.im:3000',
domain: 'http://chd.im',
showDemoWarningPopup: true,
cronTimeZone: 'Asia/Shanghai',
showDebugLog: true
showDebugLog: true,
setDefaultValueOnIndex: true
},
/**

View File

@@ -105,17 +105,20 @@ function getSafeMeanTorrentConfig(cfg) {
* @param cfg
*/
function setMeanTorrentConfigDefaultValue(req, res, cfg) {
var httpTransport = 'http://';
if (config.secure && config.secure.ssl === true) {
httpTransport = 'https://';
}
var baseUrl = req.app.get('domain') || httpTransport + req.headers.host;
if (config.meanTorrentConfig.app.setDefaultValueOnIndex) {
var httpTransport = 'http://';
if (config.secure && config.secure.ssl === true) {
httpTransport = 'https://';
}
var baseUrl = req.app.get('domain') || httpTransport + req.headers.host;
cfg.app.domain = baseUrl;
}
cfg.app.domain = baseUrl;
if (!cfg.announce.abs) {
cfg.announce.abs = cfg.announce.url;
}
cfg.announce.url = baseUrl + cfg.announce.abs;
cfg.announce.url = cfg.app.domain + cfg.announce.abs;
return cfg;
}