[英]heroku deployment with node server
我在heroku上的Web应用程序部署仍然存在问题-返回的错误未能加载资源错误404。该错误在我的本地节点服务器上完美运行,但是在推送到heroku时不加载css或js文件。 我已经看到了一些关于ruby的答案,但是关于节点的数量却很少-这是我的服务器代码:
var express = require('express');
var app = express();
// set the port of our application
// process.env.PORT lets the port be set by Heroku
var port = process.env.PORT || 8080;
// set the view engine to ejs
app.set('view engine', 'ejs');
// make express look in the public directory for assets (css/js/img)
app.use(express.static(__dirname + '/public'));
// set the home page route
app.get('/', function(req, res) {
// ejs render automatically looks in the views folder
res.render('index');
});
app.listen(port, function() {
console.log('Our app is running on http://localhost:' + port);
});
非常感谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.