Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

express框架怎么样把http请求强制转到https?

$
0
0

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.


Viewing all articles
Browse latest Browse all 14821

Trending Articles