Skip to content

Commit

Permalink
de-duplicate forceHttps
Browse files Browse the repository at this point in the history
  • Loading branch information
joelanman committed Apr 4, 2017
1 parent 34ce07c commit 047065a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ if (!useDocumentation) promoMode = 'false'
// Force HTTPs on production connections. Do this before asking for basicAuth to
// avoid making users fill in the username/password twice (once for `http`, and
// once for `https`).
if (env === 'production' && useHttps === 'true') {

var isSecure = (env === 'production' && useHttps === 'true')

if (isSecure) {
app.use(utils.forceHttps)
app.set('trust proxy', 1) // needed for secure cookies on heroku
}

// Authenticate against the environment-provided credentials, if running
Expand Down Expand Up @@ -107,15 +111,6 @@ app.locals.promoMode = promoMode
app.locals.releaseVersion = 'v' + releaseVersion
app.locals.serviceName = config.serviceName

var isSecure = false

// Force HTTPs on production connections
if (env === 'production' && useHttps === 'true') {
app.use(utils.forceHttps)
app.set('trust proxy', 1) // needed for secure cookies on heroku
isSecure = true
}

// Support session data
app.use(session({
cookie: {
Expand Down

0 comments on commit 047065a

Please sign in to comment.