node express将请求重定向为https

项目开发时,由于服务器只接受https请求,所以在生产环境时,要把所有http请求全都重定向为https,具体操作是在app.js文件里加入以下代码:

var express = require('express');
var toHttps = require('express-to-https').basic;
if(clusterUtility.API.clusterType == "release"){
    //判断只在生产环境使用此插件
    app.use(toHttps);
}
原文地址:https://www.cnblogs.com/kakayang/p/8202552.html