This commit is contained in:
Tyler Renelle 2012-10-12 08:19:13 -04:00
parent f11943349a
commit c596e897ff
2 changed files with 7 additions and 12 deletions

View file

@ -36,12 +36,6 @@ server = http.createServer(expressApp);
module.exports = server;
if (process.env.NODE_ENV === 'production' && req.headers['x-forwarded-proto'] !== 'https') {
expressApp.get('*', function(req, res, next) {
return res.redirect('https://' + req.headers.host + req.url);
});
}
derby.use(require('racer-db-mongo'));
store = derby.createStore({
@ -66,6 +60,9 @@ publicPath = path.join(root, 'public');
habitrpgMiddleware = function(req, res, next) {
var model;
if (req.headers['x-forwarded-proto'] !== 'https') {
res.redirect('https://' + req.headers.host + req.url);
}
model = req.getModel();
model.set('_mobileDevice', /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(req.header('User-Agent')));
auth.setRequest(req);

View file

@ -23,12 +23,6 @@ expressApp = express()
server = http.createServer expressApp
module.exports = server
# Force SSL
# Set before other routes, as early as possible
if process.env.NODE_ENV=='production' and req.headers['x-forwarded-proto']!='https'
expressApp.get '*', (req, res, next) ->
res.redirect('https://'+req.headers.host+req.url)
derby.use(require 'racer-db-mongo')
store = derby.createStore
db: {type: 'Mongo', uri: process.env.NODE_DB_URI}
@ -42,6 +36,10 @@ root = path.dirname path.dirname __dirname
publicPath = path.join root, 'public'
habitrpgMiddleware = (req, res, next) ->
# Force SSL
if req.headers['x-forwarded-proto']!='https'
res.redirect('https://'+req.headers.host+req.url)
model = req.getModel()
## Set _mobileDevice to true or false so view can exclude portions from mobile device
model.set '_mobileDevice', /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(req.header 'User-Agent')