Created
September 29, 2015 06:21
-
-
Save fehguy/3dd5e8f57be446034584 to your computer and use it in GitHub Desktop.
redirect
This file contains hidden or 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
//////// | |
// HTTPS | |
if(config.PRODUCTION) { | |
app.use(function(req, res, next) { | |
if((!req.secure) && (req.get('X-Forwarded-Proto') !== 'https')) { | |
res.redirect('https://' + req.get('Host') + req.url); | |
} | |
else | |
next(); | |
}); | |
} | |
//////// | |
// non-root domains | |
if(config.PRODUCTION) { | |
app.use(function(req, res, next) { | |
if(req.get('Host').toLowerCase().indexOf('swaggerhub') !== 0) { | |
res.redirect('https://swaggerhub.com' + req.url); | |
} | |
else | |
next(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment