mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 23:09:29 -07:00
Improve onion middleware
This commit is contained in:
parent
22934fff1d
commit
627890ad4c
2 changed files with 11 additions and 9 deletions
13
index.js
13
index.js
|
@ -42,13 +42,18 @@ app.set('domain', process.env.DOMAIN || "keyoxide.org")
|
||||||
app.set('keyoxide_version', packageData.version)
|
app.set('keyoxide_version', packageData.version)
|
||||||
app.set('onion_url', process.env.ONION_URL)
|
app.set('onion_url', process.env.ONION_URL)
|
||||||
|
|
||||||
|
// Middlewares
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.setHeader('Permissions-Policy', 'interest-cohort=()')
|
res.setHeader('Permissions-Policy', 'interest-cohort=()')
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
app.use('/favicon.svg', express.static('favicon.svg'))
|
if (app.get('onion_url')) {
|
||||||
app.use('/robots.txt', express.static('robots.txt'))
|
app.get('/*', (req, res, next) => {
|
||||||
|
res.header('Onion-Location', app.get('onion_url'))
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
app.use(stringReplace({
|
app.use(stringReplace({
|
||||||
PLACEHOLDER__PROXY_HOSTNAME: process.env.PROXY_HOSTNAME || 'null'
|
PLACEHOLDER__PROXY_HOSTNAME: process.env.PROXY_HOSTNAME || 'null'
|
||||||
|
@ -56,6 +61,10 @@ app.use(stringReplace({
|
||||||
contentTypeFilterRegexp: /application\/javascript/,
|
contentTypeFilterRegexp: /application\/javascript/,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// Routes
|
||||||
|
app.use('/favicon.svg', express.static('favicon.svg'))
|
||||||
|
app.use('/robots.txt', express.static('robots.txt'))
|
||||||
|
|
||||||
app.use('/', require('./routes/main'))
|
app.use('/', require('./routes/main'))
|
||||||
app.use('/static', require('./routes/static'))
|
app.use('/static', require('./routes/static'))
|
||||||
app.use('/util', require('./routes/util'))
|
app.use('/util', require('./routes/util'))
|
||||||
|
|
|
@ -35,13 +35,6 @@ md.use(require("markdown-it-anchor"), { "level": 2, "permalink": true, "permalin
|
||||||
md.use(require("markdown-it-table-of-contents"), { "includeLevel": [2, 3], "listType": "ol" })
|
md.use(require("markdown-it-table-of-contents"), { "includeLevel": [2, 3], "listType": "ol" })
|
||||||
md.use(require('markdown-it-title'))
|
md.use(require('markdown-it-title'))
|
||||||
|
|
||||||
if (process.env.ONION_URL) {
|
|
||||||
router.get('/*', (req, res, next) => {
|
|
||||||
res.header('Onion-Location', process.env.ONION_URL)
|
|
||||||
next()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
let highlights = []
|
let highlights = []
|
||||||
for (let index = 1; index < 4; index++) {
|
for (let index = 1; index < 4; index++) {
|
||||||
|
|
Loading…
Reference in a new issue