mirror of
https://codeberg.org/tacerus/teddit.git
synced 2025-01-09 12:52:32 +01:00
add www-redirect option
This commit is contained in:
parent
e2847c87b2
commit
8b7f699b3b
13
app.js
13
app.js
@ -37,6 +37,7 @@ global.reddit_access_token = null
|
|||||||
global.reddit_refresh_token = null
|
global.reddit_refresh_token = null
|
||||||
global.valid_media_domains = ['preview.redd.it', 'external-preview.redd.it', 'i.redd.it', 'v.redd.it', 'a.thumbs.redditmedia.com', 'b.thumbs.redditmedia.com', 'thumbs.gfycat.com', 'i.ytimg.com']
|
global.valid_media_domains = ['preview.redd.it', 'external-preview.redd.it', 'i.redd.it', 'v.redd.it', 'a.thumbs.redditmedia.com', 'b.thumbs.redditmedia.com', 'thumbs.gfycat.com', 'i.ytimg.com']
|
||||||
global.reddit_api_error_text = `Seems like your instance is either blocked (e.g. due to API rate limiting), reddit is currently down, or your API key is expired and not renewd properly. This can also happen for other reasons.`
|
global.reddit_api_error_text = `Seems like your instance is either blocked (e.g. due to API rate limiting), reddit is currently down, or your API key is expired and not renewd properly. This can also happen for other reasons.`
|
||||||
|
global.redirect_www = true
|
||||||
|
|
||||||
const pug = require('pug')
|
const pug = require('pug')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
@ -76,6 +77,18 @@ if(https_enabled) {
|
|||||||
|
|
||||||
const http = require('http').Server(app)
|
const http = require('http').Server(app)
|
||||||
|
|
||||||
|
if(redirect_www) {
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
if(req.headers.host) {
|
||||||
|
if(req.headers.host.slice(0, 4) === 'www.') {
|
||||||
|
let newhost = req.headers.host.slice(4)
|
||||||
|
return res.redirect(301, req.protocol + '://' + newhost + req.originalUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if(use_helmet && https_enabled) {
|
if(use_helmet && https_enabled) {
|
||||||
app.use(helmet())
|
app.use(helmet())
|
||||||
if(use_helmet_hsts) {
|
if(use_helmet_hsts) {
|
||||||
|
8
dist/css/styles.css
vendored
8
dist/css/styles.css
vendored
@ -224,12 +224,12 @@ body.dark .comment .body a {
|
|||||||
color: #3d99fb;
|
color: #3d99fb;
|
||||||
}
|
}
|
||||||
body.dark header .tabmenu li.active a {
|
body.dark header .tabmenu li.active a {
|
||||||
background: #acacac;
|
background: #acacac;
|
||||||
color: #151515;
|
color: #151515;
|
||||||
}
|
}
|
||||||
body.dark #search form input[type="text"] {
|
body.dark #search form input[type="text"] {
|
||||||
background: #0f0f0f;
|
background: #0f0f0f;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
color: var(--linkcolor);
|
color: var(--linkcolor);
|
||||||
|
Loading…
Reference in New Issue
Block a user