carthage
Version:
An API Server and Framework with scaffold functions for node.js
27 lines (16 loc) • 479 B
JavaScript
;
const Carthage = require('carthage');
/* Forces HTTPS */
class ForceHTTPSMiddleware {
exec(controller, callback) {
let headers = controller._requestHeaders;
let host = headers.host || '';
if (headers.hasOwnProperty('x-forwarded-proto') &&
headers['x-forwarded-proto'] !== 'https') {
controller.redirect(`https://${host}${controller._path}`);
return;
}
callback(null);
}
}
module.exports = ForceHTTPSMiddleware;