diff --git a/config.js.template b/config.js.template index 598065e..8c8eeeb 100644 --- a/config.js.template +++ b/config.js.template @@ -6,6 +6,7 @@ const config = { flairs_enabled: !('FLAIRS_ENABLED' in process.env) || process.env.FLAIRS_ENABLED === 'true', // Enables the rendering of user and link flairs on teddit highlight_controversial: !('HIGHLIGHT_CONTROVERSIAL' in process.env) || process.env.HIGHLIGHT_CONTROVERSIAL === 'true', // Enables controversial comments to be indicated by a typographical dagger (†) api_enabled: !('API_ENABLED' in process.env) || process.env.API_ENABLED === 'true', // Teddit API feature. Might increase loads significantly on your instance. + api_force_https: process.env.API_FORCE_HTTPS === 'true' || false, video_enabled: !('VIDEO_ENABLED' in process.env) || process.env.VIDEO_ENABLED === 'true', redis_enabled: !('REDIS_ENABLED' in process.env) || process.env.REDIS_ENABLED === 'true', // If disabled, does not cache Reddit API calls redis_db: process.env.REDIS_DB, diff --git a/inc/teddit_api/handleSubreddit.js b/inc/teddit_api/handleSubreddit.js index 98fd0ac..3925be6 100644 --- a/inc/teddit_api/handleSubreddit.js +++ b/inc/teddit_api/handleSubreddit.js @@ -25,7 +25,7 @@ module.exports = function () { if (from === 'redis') json = JSON.parse(json); if (api_type === 'rss') { - let protocol = config.https_enabled ? 'https' : 'http'; + let protocol = config.https_enabled || config.api_force_https ? 'https' : 'http'; let items = ''; for (var i = 0; i < json.data.children.length; i++) { let link = json.data.children[i].data; @@ -149,7 +149,7 @@ module.exports = function () { req.cookies ); - let protocol = config.https_enabled ? 'https' : 'http'; + let protocol = config.https_enabled || config.api_force_https ? 'https' : 'http'; for (var i = 0; i < processed_json.links.length; i++) { let link = processed_json.links[i]; let valid_reddit_self_domains = ['reddit.com']; diff --git a/inc/teddit_api/handleUser.js b/inc/teddit_api/handleUser.js index f07c2bb..1d86221 100644 --- a/inc/teddit_api/handleUser.js +++ b/inc/teddit_api/handleUser.js @@ -23,7 +23,7 @@ module.exports = function () { let _json = json; // Keep the original json if (from === 'redis') json = JSON.parse(json); - let protocol = config.https_enabled ? 'https' : 'http'; + let protocol = config.https_enabled || config.api_force_https ? 'https' : 'http'; let link = `${protocol}://${config.domain}/user/${user}`; if (api_type === 'rss') {