我在Heroku应用程序中为静态视图提供错误。奇怪的是,Heroku似乎在我的静态文件路径的前面添加了“app”,我不知道为什么。路径应该是“public/views/index.html”。错误:ENOENT,stat'/app/public/views/index.html'在Heroku
我最近尝试从堆栈这个提议的解决方案,但它似乎没有工作:Node.js, can't open files. Error: ENOENT, stat './path/to/file'
从我的服务器的GET请求:
app.use(express.static(__dirname + '/public'));
app.get('/', function (req, res) {
res.sendFile(__dirname + '/public/views/index.html');
});
// profile page
app.get('/profile', function (req, res) {
// check for current (logged-in) user
req.currentUser(function (err, user) {
// show profile if logged-in user
if (user) {
res.sendFile(__dirname + '/public/views/profile.html');
// redirect if no user logged in
} else {
res.redirect('/');
}
});
});
没有人有任何想法,为什么会的Heroku追加“应用程序”我的路径?
所有路径在本地服务器上正常工作。谢谢!