Merge pull request #2978 from overleaf/jpa-expose-hostname

[misc] optionally expose the hostname in the X-Served-By response header

GitOrigin-RevId: f3ac14aeb75cef8c9ed1d8cb1d649dd7f909b99b
This commit is contained in:
Jakob Ackermann 2020-07-07 14:55:42 +02:00 committed by Copybot
parent f0f29e2f17
commit ae068781ca
2 changed files with 10 additions and 0 deletions

View file

@ -72,6 +72,13 @@ if (Settings.behindProxy) {
next() next()
}) })
} }
if (Settings.exposeHostname) {
const HOSTNAME = require('os').hostname()
app.use((req, res, next) => {
res.setHeader('X-Served-By', HOSTNAME)
next()
})
}
webRouter.use( webRouter.use(
express.static(Path.join(__dirname, '/../../../public'), { express.static(Path.join(__dirname, '/../../../public'), {

View file

@ -418,6 +418,9 @@ module.exports = settings =
# address and http/https protocol information. # address and http/https protocol information.
behindProxy: false behindProxy: false
# Expose the hostname in the `X-Served-By` response header
exposeHostname: process.env['EXPOSE_HOSTNAME'] == 'true'
# Cookie max age (in milliseconds). Set to false for a browser session. # Cookie max age (in milliseconds). Set to false for a browser session.
cookieSessionLength: 5 * 24 * 60 * 60 * 1000 # 5 days cookieSessionLength: 5 * 24 * 60 * 60 * 1000 # 5 days