express框架怎么样把http请求强制转到https?
app.all('*', function (req, res, next) {
if(req.protocol !== 'https') {
res.redirect(301, 'https://' + req.get('host') + req.originalUrl);
}
return next();
})
出现error 怎么解决?
rror: Can't set headers after they are sent.