[英]How to do I get at my frontend on Heroku? The backend is up & running
I finally got my node/express & mongodb running on Heroku...but how do I get at my frontend? 我终于在Heroku上运行了我的node / express和mongodb ...但是如何获得我的前端呢?
I am most familiar with a localHost setup, where I simply open my index.html, running localHost servers with MAMP.. 我对localHost设置最熟悉,在这里我只需打开index.html,并使用MAMP运行localHost服务器。
When I load myapp.herokuapp.com, I see a JSON of my MongoDB docs (currently empty) 加载myapp.herokuapp.com时,我看到了MongoDB文档的JSON(当前为空)
{
"docs": []
}
And when I go to myapp.heroku.com/index.html I get my 404 error.. 当我访问myapp.heroku.com/index.html时,出现了404错误。
Where.. 404
This all makes sense, according to my express code: 根据我的明确代码,这一切都说得通:
app.get('/', function (req, res) {
getAll(res);
});
app.get('*', function (req, res) {
res.send("Where.. 404", 404);
});
How do I get to my index.html frontend? 我如何到达index.html前端? Is there any more code that would be helpful to see..
还有更多的代码将对您有所帮助。
what app.use() calls do you have? 您有什么app.use()调用?
In particular, if you want to serve static .html files you need to add something along these lines (assuming your static file are located in the ./public
sub-dir): 特别是,如果要提供静态.html文件,则需要沿以下
./public
行添加一些内容(假设您的静态文件位于./public
子目录中):
app.use(express.static(__dirname + '/public'));
Further details: http://expressjs.com/api.html#app.use 更多详细信息: http : //expressjs.com/api.html#app.use
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.