mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-26 00:59:24 +01:00
Add http(s) proxy support
This commit is contained in:
parent
0d180c2c5e
commit
73a8391f2e
@ -85,6 +85,7 @@ The following variables may be set to customize your deployment at runtime.
|
|||||||
| use_helmet_hsts | *Boolean* Recommended to be true when using https. Defaults to **false** |
|
| use_helmet_hsts | *Boolean* Recommended to be true when using https. Defaults to **false** |
|
||||||
| trust_proxy | *Boolean* Enable trust_proxy if you are using a reverse proxy like nginx or traefik. Defaults to **false** |
|
| trust_proxy | *Boolean* Enable trust_proxy if you are using a reverse proxy like nginx or traefik. Defaults to **false** |
|
||||||
| trust_proxy_address | Location of trust_proxy. Defaults to **127.0.0.1** |
|
| trust_proxy_address | Location of trust_proxy. Defaults to **127.0.0.1** |
|
||||||
|
| http_proxy | Set http/https proxy to use for outgoing requests. See [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) for details |
|
||||||
| nsfw_enabled | *Boolean* Enable NSFW (over 18) content. If false, a warning is shown to the user before opening any NSFW post. When the NFSW content is disabled, NSFW posts are hidden from subreddits and from user page feeds. Note: Users can set this to true or false from their preferences. Defaults to **true** |
|
| nsfw_enabled | *Boolean* Enable NSFW (over 18) content. If false, a warning is shown to the user before opening any NSFW post. When the NFSW content is disabled, NSFW posts are hidden from subreddits and from user page feeds. Note: Users can set this to true or false from their preferences. Defaults to **true** |
|
||||||
| post_comments_sort | Defines default sort preference. Options are *confidence* (default sorting option in Reddit), *top*, *new*, *controversal*, *old*, *random*, *qa*, *live*. Defaults to **confidence** |
|
| post_comments_sort | Defines default sort preference. Options are *confidence* (default sorting option in Reddit), *top*, *new*, *controversal*, *old*, *random*, *qa*, *live*. Defaults to **confidence** |
|
||||||
| reddit_app_id | If "use_reddit_oauth" config key is set to true, you have to obtain your Reddit app ID. For testing purposes it's okay to use this project's default app ID. Create your Reddit app here: https://old.reddit.com/prefs/apps/. Make sure to create an "installed app" type of app. Default is **ABfYqdDc9qPh1w** |
|
| reddit_app_id | If "use_reddit_oauth" config key is set to true, you have to obtain your Reddit app ID. For testing purposes it's okay to use this project's default app ID. Create your Reddit app here: https://old.reddit.com/prefs/apps/. Make sure to create an "installed app" type of app. Default is **ABfYqdDc9qPh1w** |
|
||||||
|
16
app.js
16
app.js
@ -45,9 +45,23 @@ const redis = (() => {
|
|||||||
|
|
||||||
return r.createClient(redisOptions)
|
return r.createClient(redisOptions)
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
const nodeFetch = require('node-fetch')
|
||||||
|
const fetch = config.http_proxy
|
||||||
|
? (() => {
|
||||||
|
const agent = require('https-proxy-agent')(config.http_proxy)
|
||||||
|
return (url, options) => {
|
||||||
|
const instanceOptions = {
|
||||||
|
agent,
|
||||||
|
...options
|
||||||
|
};
|
||||||
|
return nodeFetch(url, instanceOptions);
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
: nodeFetch
|
||||||
|
|
||||||
const helmet = require('helmet')
|
const helmet = require('helmet')
|
||||||
const bodyParser = require('body-parser')
|
const bodyParser = require('body-parser')
|
||||||
const fetch = require('node-fetch')
|
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const app = express()
|
const app = express()
|
||||||
const request = require('postman-request')
|
const request = require('postman-request')
|
||||||
|
@ -24,6 +24,7 @@ const config = {
|
|||||||
use_helmet_hsts: process.env.USE_HELMET_HSTS === 'true' || false, // Recommended to be true when using https
|
use_helmet_hsts: process.env.USE_HELMET_HSTS === 'true' || false, // Recommended to be true when using https
|
||||||
trust_proxy: process.env.TRUST_PROXY === 'true' || false, // Enable trust_proxy if you are using reverse proxy like nginx
|
trust_proxy: process.env.TRUST_PROXY === 'true' || false, // Enable trust_proxy if you are using reverse proxy like nginx
|
||||||
trust_proxy_address: process.env.TRUST_PROXY_ADDRESS || '127.0.0.1',
|
trust_proxy_address: process.env.TRUST_PROXY_ADDRESS || '127.0.0.1',
|
||||||
|
http_proxy: process.env.HTTP_PROXY,
|
||||||
nsfw_enabled: process.env.NSFW_ENABLED !== 'true' || true, // Enable NSFW (over 18) content. If false, a warning is shown to the user before opening any NSFW post. When the NFSW content is disabled, NSFW posts are hidden from subreddits and from user page feeds. Note: Users can set this to true or false from their preferences.
|
nsfw_enabled: process.env.NSFW_ENABLED !== 'true' || true, // Enable NSFW (over 18) content. If false, a warning is shown to the user before opening any NSFW post. When the NFSW content is disabled, NSFW posts are hidden from subreddits and from user page feeds. Note: Users can set this to true or false from their preferences.
|
||||||
videos_muted: process.env.VIDEOS_MUTED !== 'true' || true, // Automatically mute all videos in posts
|
videos_muted: process.env.VIDEOS_MUTED !== 'true' || true, // Automatically mute all videos in posts
|
||||||
post_comments_sort: process.env.POST_COMMENTS_SORT || 'confidence', // "confidence" is the default sorting in Reddit. Must be one of: confidence, top, new, controversial, old, random, qa, live.
|
post_comments_sort: process.env.POST_COMMENTS_SORT || 'confidence', // "confidence" is the default sorting in Reddit. Must be one of: confidence, top, new, controversial, old, random, qa, live.
|
||||||
|
1512
package-lock.json
generated
1512
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,7 @@
|
|||||||
"cookie-parser": "^1.4.5",
|
"cookie-parser": "^1.4.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"helmet": "^4.6.0",
|
"helmet": "^4.6.0",
|
||||||
|
"https-proxy-agent": "^5.0.0",
|
||||||
"minizlib": "^2.1.2",
|
"minizlib": "^2.1.2",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"postman-request": "^2.88.1-postman.30",
|
"postman-request": "^2.88.1-postman.30",
|
||||||
|
Loading…
Reference in New Issue
Block a user