Last active
December 14, 2015 12:38
-
-
Save timsavery/5087481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = express(); | |
app.configure(function() { | |
app.set('port', process.env.PORT || 3000); | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'jade'); | |
app.use(express.favicon()); | |
app.use(express.logger('dev')); | |
app.use(function (req, res, next) { | |
console.log('in redirect'); | |
res.setHeader('Strict-Transport-Security', 'max-age=8640000; includeSubDomains') | |
console.log('set header'); | |
if (req.headers['x-forwarded-proto'] !== 'https') { | |
var dest = 'https://' + req.headers.host + '/'; | |
console.log('redirecting to ' + dest); | |
return res.redirect(301, dest); | |
} | |
}); | |
app.use(express.bodyParser()); | |
app.use(express.methodOverride()); | |
app.use(express.cookieParser('*****')); | |
app.use(express.session()); | |
app.use(expressValidator); | |
app.use(app.router); | |
app.use(require('stylus').middleware(__dirname + '/public')); | |
app.use(express.static(path.join(__dirname, 'public'))); | |
}); | |
... | |
app.get('/', routes.index); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment