项目开发时,由于服务器只接受https请求,所以在生产环境时,要把所有http请求全都重定向为https,具体操作是在app.js文件里加入以下代码:
var express = require('express'); var toHttps = require('express-to-https').basic; if(clusterUtility.API.clusterType == "release"){ //判断只在生产环境使用此插件 app.use(toHttps); }