我在运行快速应用程序时遇到问题,在运行server.js时它会正确启动该应用程序,并在浏览器中尝试运行localhost:3000
时会拒绝运行并表示无法访问该站点。在Windows机器上运行。可能是什么问题?以下是我的代码
var app = express();
var hbs = exphbs.create({ defaultLayout: 'main', extname: ".hbs",
helpers: require('./helpers/hbs_helpers.js'), partialsDir: 'views/partials' });
app.listen(Number(process.env.PORT || 3000));
app.engine('hbs', hbs.engine);
app.set('view engine', 'hbs');
// redirect ssl
if (process.env.MODE != "development") {
app.use(function(req, res, next) {
if (req.headers['x-forwarded-proto'] !== 'https') {
return res.redirect(['https://', req.get('Host'), req.url].join(''));
}
next();
});
}