add a config to force https for api permalinks (#285)
This commit is contained in:
parent
bc274e9660
commit
15256b1cd8
|
@ -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,
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -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') {
|
||||
|
|
Loading…
Reference in New Issue