forked from Mirrors/keyoxide-web
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('onion_url', process.env.ONION_URL)
|
||||
|
||||
// Middlewares
|
||||
app.use((req, res, next) => {
|
||||
res.setHeader('Permissions-Policy', 'interest-cohort=()')
|
||||
next()
|
||||
})
|
||||
|
||||
app.use('/favicon.svg', express.static('favicon.svg'))
|
||||
app.use('/robots.txt', express.static('robots.txt'))
|
||||
if (app.get('onion_url')) {
|
||||
app.get('/*', (req, res, next) => {
|
||||
res.header('Onion-Location', app.get('onion_url'))
|
||||
next()
|
||||
})
|
||||
}
|
||||
|
||||
app.use(stringReplace({
|
||||
PLACEHOLDER__PROXY_HOSTNAME: process.env.PROXY_HOSTNAME || 'null'
|
||||
|
@ -56,6 +61,10 @@ app.use(stringReplace({
|
|||
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('/static', require('./routes/static'))
|
||||
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-title'))
|
||||
|
||||
if (process.env.ONION_URL) {
|
||||
router.get('/*', (req, res, next) => {
|
||||
res.header('Onion-Location', process.env.ONION_URL)
|
||||
next()
|
||||
})
|
||||
}
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
let highlights = []
|
||||
for (let index = 1; index < 4; index++) {
|
||||
|
|
Loading…
Reference in a new issue