mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-06 14:48:52 +02:00
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:
2
config/env/default.js
vendored
2
config/env/default.js
vendored
@@ -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
|
||||
|
||||
9
config/env/torrents.js
vendored
9
config/env/torrents.js
vendored
@@ -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
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user