node.js - node js Hapi js and heroku how to handle https -
i want allow https traffic hapi js server.
in thread: node.js, express , heroku - how handle http , https?
it accomplished by:
if (process.env.node_env == 'production') { app.use(function (req, res, next) { res.setheader('strict-transport-security', 'max-age=8640000; includesubdomains'); if (req.headers['x-forwarded-proto'] && req.headers['x-forwarded-proto'] === "http") { return res.redirect(301, 'https://' + req.host + req.url); } else { return next(); } }); }
this npm module this: https://www.npmjs.org/package/hapi-require-https
Comments
Post a Comment